var fabric=fabric||{version:"1.6.2"};if(typeof exports!=="undefined"){exports.fabric=fabric}if(typeof document!=="undefined"&&typeof window!=="undefined"){fabric.document=document;fabric.window=window;window.fabric=fabric}else{fabric.document=require("jsdom").jsdom("<!DOCTYPE html><html><head></head><body></body></html>");if(fabric.document.createWindow){fabric.window=fabric.document.createWindow()}else{fabric.window=fabric.document.parentWindow}}fabric.isTouchSupported="ontouchstart"in fabric.document.documentElement;fabric.isLikelyNode=typeof Buffer!=="undefined"&&typeof window==="undefined";fabric.SHARED_ATTRIBUTES=["display","transform","fill","fill-opacity","fill-rule","opacity","stroke","stroke-dasharray","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width","id"];fabric.DPI=96;fabric.reNum="(?:[-+]?(?:\\d+|\\d*\\.\\d+)(?:e[-+]?\\d+)?)";fabric.fontPaths={};fabric.devicePixelRatio=fabric.window.devicePixelRatio||fabric.window.webkitDevicePixelRatio||fabric.window.mozDevicePixelRatio||1;(function(){function t(t,e){if(!this.__eventListeners[t]){return}var i=this.__eventListeners[t];if(e){i[i.indexOf(e)]=false}else{fabric.util.array.fill(i,false)}}function e(t,e){if(!this.__eventListeners){this.__eventListeners={}}if(arguments.length===1){for(var i in t){this.on(i,t[i])}}else{if(!this.__eventListeners[t]){this.__eventListeners[t]=[]}this.__eventListeners[t].push(e)}return this}function i(e,i){if(!this.__eventListeners){return}if(arguments.length===0){for(e in this.__eventListeners){t.call(this,e)}}else if(arguments.length===1&&typeof arguments[0]==="object"){for(var r in e){t.call(this,r,e[r])}}else{t.call(this,e,i)}return this}function r(t,e){if(!this.__eventListeners){return}var i=this.__eventListeners[t];if(!i){return}for(var r=0,s=i.length;r<s;r++){i[r]&&i[r].call(this,e||{})}this.__eventListeners[t]=i.filter(function(t){return t!==false});return this}fabric.Observable={observe:e,stopObserving:i,fire:r,on:e,off:i,trigger:r}})();fabric.Collection={add:function(){this._objects.push.apply(this._objects,arguments);for(var t=0,e=arguments.length;t<e;t++){this._onObjectAdded(arguments[t])}this.renderOnAddRemove&&this.renderAll();return this},insertAt:function(t,e,i){var r=this.getObjects();if(i){r[e]=t}else{r.splice(e,0,t)}this._onObjectAdded(t);this.renderOnAddRemove&&this.renderAll();return this},remove:function(){var t=this.getObjects(),e;for(var i=0,r=arguments.length;i<r;i++){e=t.indexOf(arguments[i]);if(e!==-1){t.splice(e,1);this._onObjectRemoved(arguments[i])}}this.renderOnAddRemove&&this.renderAll();return this},forEachObject:function(t,e){var i=this.getObjects(),r=i.length;while(r--){t.call(e,i[r],r,i)}return this},getObjects:function(t){if(typeof t==="undefined"){return this._objects}return this._objects.filter(function(e){return e.type===t})},item:function(t){return this.getObjects()[t]},isEmpty:function(){return this.getObjects().length===0},size:function(){return this.getObjects().length},contains:function(t){return this.getObjects().indexOf(t)>-1},complexity:function(){return this.getObjects().reduce(function(t,e){t+=e.complexity?e.complexity():0;return t},0)}};(function(t){var e=Math.sqrt,i=Math.atan2,r=Math.pow,s=Math.abs,n=Math.PI/180;fabric.util={removeFromArray:function(t,e){var i=t.indexOf(e);if(i!==-1){t.splice(i,1)}return t},getRandomInt:function(t,e){return Math.floor(Math.random()*(e-t+1))+t},degreesToRadians:function(t){return t*n},radiansToDegrees:function(t){return t/n},rotatePoint:function(t,e,i){t.subtractEquals(e);var r=fabric.util.rotateVector(t,i);return new fabric.Point(r.x,r.y).addEquals(e)},rotateVector:function(t,e){var i=Math.sin(e),r=Math.cos(e),s=t.x*r-t.y*i,n=t.x*i+t.y*r;return{x:s,y:n}},transformPoint:function(t,e,i){if(i){return new fabric.Point(e[0]*t.x+e[2]*t.y,e[1]*t.x+e[3]*t.y)}return new fabric.Point(e[0]*t.x+e[2]*t.y+e[4],e[1]*t.x+e[3]*t.y+e[5])},makeBoundingBoxFromPoints:function(t){var e=[t[0].x,t[1].x,t[2].x,t[3].x],i=fabric.util.array.min(e),r=fabric.util.array.max(e),s=Math.abs(i-r),n=[t[0].y,t[1].y,t[2].y,t[3].y],o=fabric.util.array.min(n),a=fabric.util.array.max(n),h=Math.abs(o-a);return{left:i,top:o,width:s,height:h}},invertTransform:function(t){var e=1/(t[0]*t[3]-t[1]*t[2]),i=[e*t[3],-e*t[1],-e*t[2],e*t[0]],r=fabric.util.transformPoint({x:t[4],y:t[5]},i,true);i[4]=-r.x;i[5]=-r.y;return i},toFixed:function(t,e){return parseFloat(Number(t).toFixed(e))},parseUnit:function(t,e){var i=/\D{0,2}$/.exec(t),r=parseFloat(t);if(!e){e=fabric.Text.DEFAULT_SVG_FONT_SIZE}switch(i[0]){case"mm":return r*fabric.DPI/25.4;case"cm":return r*fabric.DPI/2.54;case"in":return r*fabric.DPI;case"pt":return r*fabric.DPI/72;case"pc":return r*fabric.DPI/72*12;case"em":return r*e;default:return r}},falseFunction:function(){return false},getKlass:function(t,e){t=fabric.util.string.camelize(t.charAt(0).toUpperCase()+t.slice(1));return fabric.util.resolveNamespace(e)[t]},resolveNamespace:function(e){if(!e){return fabric}var i=e.split("."),r=i.length,s=t||fabric.window;for(var n=0;n<r;++n){s=s[i[n]]}return s},loadImage:function(t,e,i,r){if(!t){e&&e.call(i,t);return}var s=fabric.util.createImage();s.onload=function(){e&&e.call(i,s);s=s.onload=s.onerror=null};s.onerror=function(){fabric.log("Error loading "+s.src);e&&e.call(i,null,true);s=s.onload=s.onerror=null};if(t.indexOf("data")!==0&&r){s.crossOrigin=r}s.src=t},enlivenObjects:function(t,e,i,r){t=t||[];function s(){if(++o===a){e&&e(n)}}var n=[],o=0,a=t.length;if(!a){e&&e(n);return}t.forEach(function(t,e){if(!t||!t.type){s();return}var o=fabric.util.getKlass(t.type,i);if(o.async){o.fromObject(t,function(i,o){if(!o){n[e]=i;r&&r(t,n[e])}s()})}else{n[e]=o.fromObject(t);r&&r(t,n[e]);s()}})},groupSVGElements:function(t,e,i){var r;r=new fabric.PathGroup(t,e);if(typeof i!=="undefined"){r.setSourcePath(i)}return r},populateWithProperties:function(t,e,i){if(i&&Object.prototype.toString.call(i)==="[object Array]"){for(var r=0,s=i.length;r<s;r++){if(i[r]in t){e[i[r]]=t[i[r]]}}}},drawDashedLine:function(t,r,s,n,o,a){var h=n-r,c=o-s,l=e(h*h+c*c),f=i(c,h),u=a.length,d=0,g=true;t.save();t.translate(r,s);t.moveTo(0,0);t.rotate(f);r=0;while(l>r){r+=a[d++%u];if(r>l){r=l}t[g?"lineTo":"moveTo"](r,0);g=!g}t.restore()},createCanvasElement:function(t){t||(t=fabric.document.createElement("canvas"));if(!t.getContext&&typeof G_vmlCanvasManager!=="undefined"){G_vmlCanvasManager.initElement(t)}return t},createImage:function(){return fabric.isLikelyNode?new(require("canvas").Image):fabric.document.createElement("img")},createAccessors:function(t){var e=t.prototype;for(var i=e.stateProperties.length;i--;){var r=e.stateProperties[i],s=r.charAt(0).toUpperCase()+r.slice(1),n="set"+s,o="get"+s;if(!e[o]){e[o]=function(t){return new Function('return this.get("'+t+'")')}(r)}if(!e[n]){e[n]=function(t){return new Function("value",'return this.set("'+t+'", value)')}(r)}}},clipContext:function(t,e){e.save();e.beginPath();t.clipTo(e);e.clip()},multiplyTransformMatrices:function(t,e,i){return[t[0]*e[0]+t[2]*e[1],t[1]*e[0]+t[3]*e[1],t[0]*e[2]+t[2]*e[3],t[1]*e[2]+t[3]*e[3],i?0:t[0]*e[4]+t[2]*e[5]+t[4],i?0:t[1]*e[4]+t[3]*e[5]+t[5]]},qrDecompose:function(t){var s=i(t[1],t[0]),o=r(t[0],2)+r(t[1],2),a=e(o),h=(t[0]*t[3]-t[2]*t[1])/a,c=i(t[0]*t[2]+t[1]*t[3],o);return{angle:s/n,scaleX:a,scaleY:h,skewX:c/n,skewY:0,translateX:t[4],translateY:t[5]}},customTransformMatrix:function(t,e,i){var r=[1,0,s(Math.tan(i*n)),1],o=[s(t),0,0,s(e)];return fabric.util.multiplyTransformMatrices(o,r,true)},resetObjectTransform:function(t){t.scaleX=1;t.scaleY=1;t.skewX=0;t.skewY=0;t.flipX=false;t.flipY=false;t.setAngle(0)},getFunctionBody:function(t){return(String(t).match(/function[^{]*\{([\s\S]*)\}/)||{})[1]},isTransparent:function(t,e,i,r){if(r>0){if(e>r){e-=r}else{e=0}if(i>r){i-=r}else{i=0}}var s=true,n=t.getImageData(e,i,r*2||1,r*2||1);for(var o=3,a=n.data.length;o<a;o+=4){var h=n.data[o];s=h<=0;if(s===false){break}}n=null;return s},parsePreserveAspectRatioAttribute:function(t){var e="meet",i="Mid",r="Mid",s=t.split(" "),n;if(s&&s.length){e=s.pop();if(e!=="meet"&&e!=="slice"){n=e;e="meet"}else if(s.length){n=s.pop()}}i=n!=="none"?n.slice(1,4):"none";r=n!=="none"?n.slice(5,8):"none";return{meetOrSlice:e,alignX:i,alignY:r}}}})(typeof exports!=="undefined"?exports:this);(function(){var t={},e={},i={},r=Array.prototype.join;function s(e,i,s,a,h,c,l){var f=r.call(arguments);if(t[f]){return t[f]}var u=Math.PI,d=l*u/180,g=Math.sin(d),p=Math.cos(d),v=0,m=0;s=Math.abs(s);a=Math.abs(a);var b=-p*e*.5-g*i*.5,y=-p*i*.5+g*e*.5,_=s*s,x=a*a,S=y*y,C=b*b,w=_*x-_*S-x*C,O=0;if(w<0){var T=Math.sqrt(1-w/(_*x));s*=T;a*=T}else{O=(h===c?-1:1)*Math.sqrt(w/(_*S+x*C))}var k=O*s*y/a,j=-O*a*b/s,A=p*k-g*j+e*.5,M=g*k+p*j+i*.5,P=o(1,0,(b-k)/s,(y-j)/a),L=o((b-k)/s,(y-j)/a,(-b-k)/s,(-y-j)/a);if(c===0&&L>0){L-=2*u}else if(c===1&&L<0){L+=2*u}var D=Math.ceil(Math.abs(L/u*2)),E=[],I=L/D,R=8/3*Math.sin(I/4)*Math.sin(I/4)/Math.sin(I/2),B=P+I;for(var F=0;F<D;F++){E[F]=n(P,B,p,g,s,a,A,M,R,v,m);v=E[F][4];m=E[F][5];P=B;B+=I}t[f]=E;return E}function n(t,i,s,n,o,a,h,c,l,f,u){var d=r.call(arguments);if(e[d]){return e[d]}var g=Math.cos(t),p=Math.sin(t),v=Math.cos(i),m=Math.sin(i),b=s*o*v-n*a*m+h,y=n*o*v+s*a*m+c,_=f+l*(-s*o*p-n*a*g),x=u+l*(-n*o*p+s*a*g),S=b+l*(s*o*m+n*a*v),C=y+l*(n*o*m-s*a*v);e[d]=[_,x,S,C,b,y];return e[d]}function o(t,e,i,r){var s=Math.atan2(e,t),n=Math.atan2(r,i);if(n>=s){return n-s}else{return 2*Math.PI-(s-n)}}fabric.util.drawArc=function(t,e,i,r){var n=r[0],o=r[1],a=r[2],h=r[3],c=r[4],l=r[5],f=r[6],u=[[],[],[],[]],d=s(l-e,f-i,n,o,h,c,a);for(var g=0,p=d.length;g<p;g++){u[g][0]=d[g][0]+e;u[g][1]=d[g][1]+i;u[g][2]=d[g][2]+e;u[g][3]=d[g][3]+i;u[g][4]=d[g][4]+e;u[g][5]=d[g][5]+i;t.bezierCurveTo.apply(t,u[g])}};fabric.util.getBoundsOfArc=function(t,e,i,r,n,o,h,c,l){var f=0,u=0,d=[],g=[],p=s(c-t,l-e,i,r,o,h,n),v=[[],[]];for(var m=0,b=p.length;m<b;m++){d=a(f,u,p[m][0],p[m][1],p[m][2],p[m][3],p[m][4],p[m][5]);v[0].x=d[0].x+t;v[0].y=d[0].y+e;v[1].x=d[1].x+t;v[1].y=d[1].y+e;g.push(v[0]);g.push(v[1]);f=p[m][4];u=p[m][5]}return g};function a(t,e,s,n,o,a,h,c){var l=r.call(arguments);if(i[l]){return i[l]}var f=Math.sqrt,u=Math.min,d=Math.max,g=Math.abs,p=[],v=[[],[]],m,b,y,_,x,S,C,w;b=6*t-12*s+6*o;m=-3*t+9*s-9*o+3*h;y=3*s-3*t;for(var O=0;O<2;++O){if(O>0){b=6*e-12*n+6*a;m=-3*e+9*n-9*a+3*c;y=3*n-3*e}if(g(m)<1e-12){if(g(b)<1e-12){continue}_=-y/b;if(0<_&&_<1){p.push(_)}continue}C=b*b-4*y*m;if(C<0){continue}w=f(C);x=(-b+w)/(2*m);if(0<x&&x<1){p.push(x)}S=(-b-w)/(2*m);if(0<S&&S<1){p.push(S)}}var T,k,j=p.length,A=j,M;while(j--){_=p[j];M=1-_;T=M*M*M*t+3*M*M*_*s+3*M*_*_*o+_*_*_*h;v[0][j]=T;k=M*M*M*e+3*M*M*_*n+3*M*_*_*a+_*_*_*c;v[1][j]=k}v[0][A]=t;v[1][A]=e;v[0][A+1]=h;v[1][A+1]=c;var P=[{x:u.apply(null,v[0]),y:u.apply(null,v[1])},{x:d.apply(null,v[0]),y:d.apply(null,v[1])}];i[l]=P;return P}fabric.util.getBoundsOfCurve=a})();(function(){var t=Array.prototype.slice;if(!Array.prototype.indexOf){Array.prototype.indexOf=function(t){if(this===void 0||this===null){throw new TypeError}var e=Object(this),i=e.length>>>0;if(i===0){return-1}var r=0;if(arguments.length>0){r=Number(arguments[1]);if(r!==r){r=0}else if(r!==0&&r!==Number.POSITIVE_INFINITY&&r!==Number.NEGATIVE_INFINITY){r=(r>0||-1)*Math.floor(Math.abs(r))}}if(r>=i){return-1}var s=r>=0?r:Math.max(i-Math.abs(r),0);for(;s<i;s++){if(s in e&&e[s]===t){return s}}return-1}}if(!Array.prototype.forEach){Array.prototype.forEach=function(t,e){for(var i=0,r=this.length>>>0;i<r;i++){if(i in this){t.call(e,this[i],i,this)}}}}if(!Array.prototype.map){Array.prototype.map=function(t,e){var i=[];for(var r=0,s=this.length>>>0;r<s;r++){if(r in this){i[r]=t.call(e,this[r],r,this)}}return i}}if(!Array.prototype.every){Array.prototype.every=function(t,e){for(var i=0,r=this.length>>>0;i<r;i++){if(i in this&&!t.call(e,this[i],i,this)){return false}}return true}}if(!Array.prototype.some){Array.prototype.some=function(t,e){for(var i=0,r=this.length>>>0;i<r;i++){if(i in this&&t.call(e,this[i],i,this)){return true}}return false}}if(!Array.prototype.filter){Array.prototype.filter=function(t,e){var i=[],r;for(var s=0,n=this.length>>>0;s<n;s++){if(s in this){r=this[s];if(t.call(e,r,s,this)){i.push(r)}}}return i}}if(!Array.prototype.reduce){Array.prototype.reduce=function(t){var e=this.length>>>0,i=0,r;if(arguments.length>1){r=arguments[1]}else{do{if(i in this){r=this[i++];break}if(++i>=e){throw new TypeError}}while(true)}for(;i<e;i++){if(i in this){r=t.call(null,r,this[i],i,this)}}return r}}function e(e,i){var r=t.call(arguments,2),s=[];for(var n=0,o=e.length;n<o;n++){s[n]=r.length?e[n][i].apply(e[n],r):e[n][i].call(e[n])}return s}function i(t,e){return n(t,e,function(t,e){return t>=e})}function r(t,e){return n(t,e,function(t,e){return t<e})}function s(t,e){var i=t.length;while(i--){t[i]=e}return t}function n(t,e,i){if(!t||t.length===0){return}var r=t.length-1,s=e?t[r][e]:t[r];if(e){while(r--){if(i(t[r][e],s)){s=t[r][e]}}}else{while(r--){if(i(t[r],s)){s=t[r]}}}return s}fabric.util.array={fill:s,invoke:e,min:r,max:i}})();(function(){function t(t,e){for(var i in e){t[i]=e[i]}return t}function e(e){return t({},e)}fabric.util.object={extend:t,clone:e}})();(function(){if(!String.prototype.trim){String.prototype.trim=function(){return this.replace(/^[\s\xA0]+/,"").replace(/[\s\xA0]+$/,"")}}function t(t){return t.replace(/-+(.)?/g,function(t,e){return e?e.toUpperCase():""})}function e(t,e){return t.charAt(0).toUpperCase()+(e?t.slice(1):t.slice(1).toLowerCase())}function i(t){return t.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/'/g,"&apos;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}fabric.util.string={camelize:t,capitalize:e,escapeXml:i}})();(function(){var t=Array.prototype.slice,e=Function.prototype.apply,i=function(){};if(!Function.prototype.bind){Function.prototype.bind=function(r){var s=this,n=t.call(arguments,1),o;if(n.length){o=function(){return e.call(s,this instanceof i?this:r,n.concat(t.call(arguments)))}}else{o=function(){return e.call(s,this instanceof i?this:r,arguments)}}i.prototype=this.prototype;o.prototype=new i;return o}}})();(function(){var t=Array.prototype.slice,e=function(){},i=function(){for(var t in{toString:1}){if(t==="toString"){return false}}return true}(),r=function(t,e,r){for(var s in e){if(s in t.prototype&&typeof t.prototype[s]==="function"&&(e[s]+"").indexOf("callSuper")>-1){t.prototype[s]=function(t){return function(){var i=this.constructor.superclass;this.constructor.superclass=r;var s=e[t].apply(this,arguments);this.constructor.superclass=i;if(t!=="initialize"){return s}}}(s)}else{t.prototype[s]=e[s]}if(i){if(e.toString!==Object.prototype.toString){t.prototype.toString=e.toString}if(e.valueOf!==Object.prototype.valueOf){t.prototype.valueOf=e.valueOf}}}};function s(){}function n(e){var i=this.constructor.superclass.prototype[e];return arguments.length>1?i.apply(this,t.call(arguments,1)):i.call(this)}function o(){var i=null,o=t.call(arguments,0);if(typeof o[0]==="function"){i=o.shift()}function a(){this.initialize.apply(this,arguments)}a.superclass=i;a.subclasses=[];if(i){s.prototype=i.prototype;a.prototype=new s;i.subclasses.push(a)}for(var h=0,c=o.length;h<c;h++){r(a,o[h],i)}if(!a.prototype.initialize){a.prototype.initialize=e}a.prototype.constructor=a;a.prototype.callSuper=n;return a}fabric.util.createClass=o})();(function(){var t="unknown";function e(t){var e=Array.prototype.slice.call(arguments,1),i,r,s=e.length;for(r=0;r<s;r++){i=typeof t[e[r]];if(!/^(?:function|object|unknown)$/.test(i)){return false}}return true}var i,r,s=function(){var t=0;return function(e){return e.__uniqueID||(e.__uniqueID="uniqueID__"+t++)}}();(function(){var t={};i=function(e){return t[e]};r=function(e,i){t[e]=i}})();function n(t,e){return{handler:e,wrappedHandler:o(t,e)}}function o(t,e){return function(r){e.call(i(t),r||fabric.window.event)}}function a(t,e){return function(i){if(f[t]&&f[t][e]){var r=f[t][e];for(var s=0,n=r.length;s<n;s++){r[s].call(this,i||fabric.window.event)}}}}var h=e(fabric.document.documentElement,"addEventListener","removeEventListener")&&e(fabric.window,"addEventListener","removeEventListener"),c=e(fabric.document.documentElement,"attachEvent","detachEvent")&&e(fabric.window,"attachEvent","detachEvent"),l={},f={},u,d;if(h){u=function(t,e,i){t.addEventListener(e,i,false)};d=function(t,e,i){t.removeEventListener(e,i,false)}}else if(c){u=function(t,e,i){var o=s(t);r(o,t);if(!l[o]){l[o]={}}if(!l[o][e]){l[o][e]=[]}var a=n(o,i);l[o][e].push(a);t.attachEvent("on"+e,a.wrappedHandler)};d=function(t,e,i){var r=s(t),n;if(l[r]&&l[r][e]){for(var o=0,a=l[r][e].length;o<a;o++){n=l[r][e][o];if(n&&n.handler===i){t.detachEvent("on"+e,n.wrappedHandler);l[r][e][o]=null}}}}}else{u=function(t,e,i){var r=s(t);if(!f[r]){f[r]={}}if(!f[r][e]){f[r][e]=[];var n=t["on"+e];if(n){f[r][e].push(n)}t["on"+e]=a(r,e)}f[r][e].push(i)};d=function(t,e,i){var r=s(t);if(f[r]&&f[r][e]){var n=f[r][e];for(var o=0,a=n.length;o<a;o++){if(n[o]===i){n.splice(o,1)}}}}}fabric.util.addListener=u;fabric.util.removeListener=d;function g(e){e||(e=fabric.window.event);var i=e.target||(typeof e.srcElement!==t?e.srcElement:null),r=fabric.util.getScrollLeftTop(i);return{x:p(e)+r.left,y:v(e)+r.top}}var p=function(e){return typeof e.clientX!==t?e.clientX:0},v=function(e){return typeof e.clientY!==t?e.clientY:0};function m(t,e,i){var r=t.type==="touchend"?"changedTouches":"touches";return t[r]&&t[r][0]?t[r][0][e]-(t[r][0][e]-t[r][0][i])||t[i]:t[i]}if(fabric.isTouchSupported){p=function(t){return m(t,"pageX","clientX")};v=function(t){return m(t,"pageY","clientY")}}fabric.util.getPointer=g;fabric.util.object.extend(fabric.util,fabric.Observable)})();(function(){function t(t,e){var i=t.style;if(!i){return t}if(typeof e==="string"){t.style.cssText+=";"+e;return e.indexOf("opacity")>-1?n(t,e.match(/opacity:\s*(\d?\.?\d*)/)[1]):t}for(var r in e){if(r==="opacity"){n(t,e[r])}else{var s=r==="float"||r==="cssFloat"?typeof i.styleFloat==="undefined"?"cssFloat":"styleFloat":r;i[s]=e[r]}}return t}var e=fabric.document.createElement("div"),i=typeof e.style.opacity==="string",r=typeof e.style.filter==="string",s=/alpha\s*\(\s*opacity\s*=\s*([^\)]+)\)/,n=function(t){return t};if(i){n=function(t,e){t.style.opacity=e;return t}}else if(r){n=function(t,e){var i=t.style;if(t.currentStyle&&!t.currentStyle.hasLayout){i.zoom=1}if(s.test(i.filter)){e=e>=.9999?"":"alpha(opacity="+e*100+")";i.filter=i.filter.replace(s,e)}else{i.filter+=" alpha(opacity="+e*100+")"}return t}}fabric.util.setStyle=t})();(function(){var t=Array.prototype.slice;function e(t){return typeof t==="string"?fabric.document.getElementById(t):t}var i,r=function(e){return t.call(e,0)};try{i=r(fabric.document.childNodes)instanceof Array}catch(s){}if(!i){r=function(t){var e=new Array(t.length),i=t.length;while(i--){e[i]=t[i]}return e}}function n(t,e){var i=fabric.document.createElement(t);for(var r in e){if(r==="class"){i.className=e[r]}else if(r==="for"){i.htmlFor=e[r]}else{i.setAttribute(r,e[r])}}return i}function o(t,e){if(t&&(" "+t.className+" ").indexOf(" "+e+" ")===-1){t.className+=(t.className?" ":"")+e}}function a(t,e,i){if(typeof e==="string"){e=n(e,i)}if(t.parentNode){t.parentNode.replaceChild(e,t)}e.appendChild(t);return e}function h(t){var e=0,i=0,r=fabric.document.documentElement,s=fabric.document.body||{scrollLeft:0,scrollTop:0};while(t&&(t.parentNode||t.host)){t=t.parentNode||t.host;if(t===fabric.document){e=s.scrollLeft||r.scrollLeft||0;i=s.scrollTop||r.scrollTop||0}else{e+=t.scrollLeft||0;i+=t.scrollTop||0}if(t.nodeType===1&&fabric.util.getElementStyle(t,"position")==="fixed"){break}}return{left:e,top:i}}function c(t){var e,i=t&&t.ownerDocument,r={left:0,top:0},s={left:0,top:0},n,o={borderLeftWidth:"left",borderTopWidth:"top",paddingLeft:"left",paddingTop:"top"};if(!i){return s}for(var a in o){s[o[a]]+=parseInt(l(t,a),10)||0}e=i.documentElement;if(typeof t.getBoundingClientRect!=="undefined"){r=t.getBoundingClientRect()}n=h(t);return{left:r.left+n.left-(e.clientLeft||0)+s.left,top:r.top+n.top-(e.clientTop||0)+s.top}}var l;if(fabric.document.defaultView&&fabric.document.defaultView.getComputedStyle){l=function(t,e){var i=fabric.document.defaultView.getComputedStyle(t,null);return i?i[e]:undefined}}else{l=function(t,e){var i=t.style[e];if(!i&&t.currentStyle){i=t.currentStyle[e]}return i}}(function(){var t=fabric.document.documentElement.style,e="userSelect"in t?"userSelect":"MozUserSelect"in t?"MozUserSelect":"WebkitUserSelect"in t?"WebkitUserSelect":"KhtmlUserSelect"in t?"KhtmlUserSelect":"";function i(t){if(typeof t.onselectstart!=="undefined"){t.onselectstart=fabric.util.falseFunction}if(e){t.style[e]="none"}else if(typeof t.unselectable==="string"){t.unselectable="on"}return t}function r(t){if(typeof t.onselectstart!=="undefined"){t.onselectstart=null}if(e){t.style[e]=""}else if(typeof t.unselectable==="string"){t.unselectable=""}return t}fabric.util.makeElementUnselectable=i;fabric.util.makeElementSelectable=r})();(function(){function t(t,e){var i=fabric.document.getElementsByTagName("head")[0],r=fabric.document.createElement("script"),s=true;r.onload=r.onreadystatechange=function(t){if(s){if(typeof this.readyState==="string"&&this.readyState!=="loaded"&&this.readyState!=="complete"){return}s=false;e(t||fabric.window.event);r=r.onload=r.onreadystatechange=null}};r.src=t;i.appendChild(r)}fabric.util.getScript=t})();fabric.util.getById=e;fabric.util.toArray=r;fabric.util.makeElement=n;fabric.util.addClass=o;fabric.util.wrapElement=a;fabric.util.getScrollLeftTop=h;fabric.util.getElementOffset=c;fabric.util.getElementStyle=l})();(function(){function t(t,e){return t+(/\?/.test(t)?"&":"?")+e}var e=function(){var t=[function(){return new ActiveXObject("Microsoft.XMLHTTP")},function(){return new ActiveXObject("Msxml2.XMLHTTP")},function(){return new ActiveXObject("Msxml2.XMLHTTP.3.0")},function(){return new XMLHttpRequest}];for(var e=t.length;e--;){try{var i=t[e]();if(i){return t[e]}}catch(r){}}}();function i(){}function r(r,s){s||(s={});var n=s.method?s.method.toUpperCase():"GET",o=s.onComplete||function(){},a=e(),h;a.onreadystatechange=function(){if(a.readyState===4){o(a);a.onreadystatechange=i}};if(n==="GET"){h=null;if(typeof s.parameters==="string"){r=t(r,s.parameters)}}a.open(n,r,true);if(n==="POST"||n==="PUT"){a.setRequestHeader("Content-Type","application/x-www-form-urlencoded")}a.send(h);return a}fabric.util.request=r})();fabric.log=function(){};fabric.warn=function(){};if(typeof console!=="undefined"){["log","warn"].forEach(function(t){if(typeof console[t]!=="undefined"&&typeof console[t].apply==="function"){fabric[t]=function(){return console[t].apply(console,arguments)}}})}(function(){function t(t){i(function(e){t||(t={});var r=e||+new Date,s=t.duration||500,n=r+s,o,a=t.onChange||function(){},h=t.abort||function(){return false},c=t.easing||function(t,e,i,r){return-i*Math.cos(t/r*(Math.PI/2))+i+e},l="startValue"in t?t.startValue:0,f="endValue"in t?t.endValue:100,u=t.byValue||f-l;t.onStart&&t.onStart();(function d(e){o=e||+new Date;var f=o>n?s:o-r;if(h()){t.onComplete&&t.onComplete();return}a(c(f,l,u,s));if(o>n){t.onComplete&&t.onComplete();return}i(d)})(r)})}var e=fabric.window.requestAnimationFrame||fabric.window.webkitRequestAnimationFrame||fabric.window.mozRequestAnimationFrame||fabric.window.oRequestAnimationFrame||fabric.window.msRequestAnimationFrame||function(t){fabric.window.setTimeout(t,1e3/60)};function i(){return e.apply(fabric.window,arguments)}fabric.util.animate=t;fabric.util.requestAnimFrame=i})();(function(){function t(t,e,i,r){if(t<Math.abs(e)){t=e;r=i/4}else{if(e===0&&t===0){r=i/(2*Math.PI)*Math.asin(1)}else{r=i/(2*Math.PI)*Math.asin(e/t)}}return{a:t,c:e,p:i,s:r}}function e(t,e,i){return t.a*Math.pow(2,10*(e-=1))*Math.sin((e*i-t.s)*(2*Math.PI)/t.p)}function i(t,e,i,r){return i*((t=t/r-1)*t*t+1)+e}function r(t,e,i,r){t/=r/2;if(t<1){return i/2*t*t*t+e}return i/2*((t-=2)*t*t+2)+e}function s(t,e,i,r){return i*(t/=r)*t*t*t+e}function n(t,e,i,r){return-i*((t=t/r-1)*t*t*t-1)+e}function o(t,e,i,r){t/=r/2;if(t<1){return i/2*t*t*t*t+e}return-i/2*((t-=2)*t*t*t-2)+e}function a(t,e,i,r){return i*(t/=r)*t*t*t*t+e}function h(t,e,i,r){return i*((t=t/r-1)*t*t*t*t+1)+e}function c(t,e,i,r){t/=r/2;if(t<1){return i/2*t*t*t*t*t+e}return i/2*((t-=2)*t*t*t*t+2)+e}function l(t,e,i,r){return-i*Math.cos(t/r*(Math.PI/2))+i+e}function f(t,e,i,r){return i*Math.sin(t/r*(Math.PI/2))+e}function u(t,e,i,r){return-i/2*(Math.cos(Math.PI*t/r)-1)+e}function d(t,e,i,r){return t===0?e:i*Math.pow(2,10*(t/r-1))+e}function g(t,e,i,r){return t===r?e+i:i*(-Math.pow(2,-10*t/r)+1)+e}function p(t,e,i,r){if(t===0){return e}if(t===r){return e+i}t/=r/2;if(t<1){return i/2*Math.pow(2,10*(t-1))+e}return i/2*(-Math.pow(2,-10*--t)+2)+e}function v(t,e,i,r){return-i*(Math.sqrt(1-(t/=r)*t)-1)+e}function m(t,e,i,r){return i*Math.sqrt(1-(t=t/r-1)*t)+e}function b(t,e,i,r){t/=r/2;if(t<1){return-i/2*(Math.sqrt(1-t*t)-1)+e}return i/2*(Math.sqrt(1-(t-=2)*t)+1)+e}function y(i,r,s,n){var o=1.70158,a=0,h=s;if(i===0){return r}i/=n;if(i===1){return r+s}if(!a){a=n*.3}var c=t(h,s,a,o);return-e(c,i,n)+r}function _(e,i,r,s){var n=1.70158,o=0,a=r;if(e===0){return i}e/=s;if(e===1){return i+r}if(!o){o=s*.3}var h=t(a,r,o,n);return h.a*Math.pow(2,-10*e)*Math.sin((e*s-h.s)*(2*Math.PI)/h.p)+h.c+i}function x(i,r,s,n){var o=1.70158,a=0,h=s;if(i===0){return r}i/=n/2;if(i===2){return r+s}if(!a){a=n*(.3*1.5)}var c=t(h,s,a,o);if(i<1){return-.5*e(c,i,n)+r}return c.a*Math.pow(2,-10*(i-=1))*Math.sin((i*n-c.s)*(2*Math.PI)/c.p)*.5+c.c+r}function S(t,e,i,r,s){if(s===undefined){s=1.70158}return i*(t/=r)*t*((s+1)*t-s)+e}function C(t,e,i,r,s){if(s===undefined){s=1.70158}return i*((t=t/r-1)*t*((s+1)*t+s)+1)+e}function w(t,e,i,r,s){if(s===undefined){s=1.70158}t/=r/2;if(t<1){return i/2*(t*t*(((s*=1.525)+1)*t-s))+e}return i/2*((t-=2)*t*(((s*=1.525)+1)*t+s)+2)+e}function O(t,e,i,r){return i-T(r-t,0,i,r)+e}function T(t,e,i,r){if((t/=r)<1/2.75){return i*(7.5625*t*t)+e}else if(t<2/2.75){return i*(7.5625*(t-=1.5/2.75)*t+.75)+e}else if(t<2.5/2.75){return i*(7.5625*(t-=2.25/2.75)*t+.9375)+e}else{return i*(7.5625*(t-=2.625/2.75)*t+.984375)+e}}function k(t,e,i,r){if(t<r/2){return O(t*2,0,i,r)*.5+e}return T(t*2-r,0,i,r)*.5+i*.5+e}fabric.util.ease={easeInQuad:function(t,e,i,r){return i*(t/=r)*t+e},easeOutQuad:function(t,e,i,r){return-i*(t/=r)*(t-2)+e},easeInOutQuad:function(t,e,i,r){t/=r/2;if(t<1){return i/2*t*t+e}return-i/2*(--t*(t-2)-1)+e},easeInCubic:function(t,e,i,r){return i*(t/=r)*t*t+e},easeOutCubic:i,easeInOutCubic:r,easeInQuart:s,easeOutQuart:n,easeInOutQuart:o,easeInQuint:a,easeOutQuint:h,easeInOutQuint:c,easeInSine:l,easeOutSine:f,easeInOutSine:u,easeInExpo:d,easeOutExpo:g,easeInOutExpo:p,easeInCirc:v,easeOutCirc:m,easeInOutCirc:b,easeInElastic:y,easeOutElastic:_,easeInOutElastic:x,easeInBack:S,easeOutBack:C,easeInOutBack:w,easeInBounce:O,easeOutBounce:T,easeInOutBounce:k}})();(function(t){"use strict";var e=t.fabric||(t.fabric={}),i=e.util.object.extend,r=e.util.string.capitalize,s=e.util.object.clone,n=e.util.toFixed,o=e.util.parseUnit,a=e.util.multiplyTransformMatrices,h=/^(path|circle|polygon|polyline|ellipse|rect|line|image|text)$/i,c=/^(symbol|image|marker|pattern|view|svg)$/i,l=/^(?:pattern|defs|symbol|metadata)$/i,f=/^(symbol|g|a|svg)$/i,u={cx:"left",x:"left",r:"radius",cy:"top",y:"top",display:"visible",visibility:"visible",transform:"transformMatrix","fill-opacity":"fillOpacity","fill-rule":"fillRule","font-family":"fontFamily","font-size":"fontSize","font-style":"fontStyle","font-weight":"fontWeight","stroke-dasharray":"strokeDashArray","stroke-linecap":"strokeLineCap","stroke-linejoin":"strokeLineJoin","stroke-miterlimit":"strokeMiterLimit","stroke-opacity":"strokeOpacity","stroke-width":"strokeWidth","text-decoration":"textDecoration","text-anchor":"originX"},d={stroke:"strokeOpacity",fill:"fillOpacity"};e.cssRules={};e.gradientDefs={};function g(t){if(t in u){return u[t]}return t}function p(t,i,r,s){var n=Object.prototype.toString.call(i)==="[object Array]",h;if((t==="fill"||t==="stroke")&&i==="none"){i=""}else if(t==="strokeDashArray"){i=i.replace(/,/g," ").split(/\s+/).map(function(t){return parseFloat(t)})}else if(t==="transformMatrix"){if(r&&r.transformMatrix){i=a(r.transformMatrix,e.parseTransformAttribute(i))}else{i=e.parseTransformAttribute(i)}}else if(t==="visible"){i=i==="none"||i==="hidden"?false:true;if(r&&r.visible===false){i=false}}else if(t==="originX"){i=i==="start"?"left":i==="end"?"right":"center"}else{h=n?i.map(o):o(i,s)}return!n&&isNaN(h)?i:h}function v(t){for(var i in d){if(typeof t[d[i]]==="undefined"||t[i]===""){continue}if(typeof t[i]==="undefined"){if(!e.Object.prototype[i]){continue}t[i]=e.Object.prototype[i]}if(t[i].indexOf("url(")===0){continue}var r=new e.Color(t[i]);t[i]=r.setAlpha(n(r.getAlpha()*t[d[i]],2)).toRgba()}return t}e.parseTransformAttribute=function(){function t(t,e){var i=e[0],r=e.length===3?e[1]:0,s=e.length===3?e[2]:0;t[0]=Math.cos(i);t[1]=Math.sin(i);t[2]=-Math.sin(i);t[3]=Math.cos(i);t[4]=r-(t[0]*r+t[2]*s);t[5]=s-(t[1]*r+t[3]*s)}function i(t,e){var i=e[0],r=e.length===2?e[1]:e[0];t[0]=i;t[3]=r}function r(t,i){t[2]=Math.tan(e.util.degreesToRadians(i[0]))}function s(t,i){t[1]=Math.tan(e.util.degreesToRadians(i[0]))}function n(t,e){t[4]=e[0];if(e.length===2){t[5]=e[1]}}var o=[1,0,0,1,0,0],a=e.reNum,h="(?:\\s+,?\\s*|,\\s*)",c="(?:(skewX)\\s*\\(\\s*("+a+")\\s*\\))",l="(?:(skewY)\\s*\\(\\s*("+a+")\\s*\\))",f="(?:(rotate)\\s*\\(\\s*("+a+")(?:"+h+"("+a+")"+h+"("+a+"))?\\s*\\))",u="(?:(scale)\\s*\\(\\s*("+a+")(?:"+h+"("+a+"))?\\s*\\))",d="(?:(translate)\\s*\\(\\s*("+a+")(?:"+h+"("+a+"))?\\s*\\))",g="(?:(matrix)\\s*\\(\\s*"+"("+a+")"+h+"("+a+")"+h+"("+a+")"+h+"("+a+")"+h+"("+a+")"+h+"("+a+")"+"\\s*\\))",p="(?:"+g+"|"+d+"|"+u+"|"+f+"|"+c+"|"+l+")",v="(?:"+p+"(?:"+h+"*"+p+")*"+")",m="^\\s*(?:"+v+"?)\\s*$",b=new RegExp(m),y=new RegExp(p,"g");return function(a){var h=o.concat(),c=[];if(!a||a&&!b.test(a)){return h}a.replace(y,function(a){var l=new RegExp(p).exec(a).filter(function(t){return t!==""&&t!=null}),f=l[1],u=l.slice(2).map(parseFloat);switch(f){case"translate":n(h,u);break;case"rotate":u[0]=e.util.degreesToRadians(u[0]);t(h,u);break;case"scale":i(h,u);break;case"skewX":r(h,u);break;case"skewY":s(h,u);break;case"matrix":h=u;break}c.push(h.concat());h=o.concat()});var l=c[0];while(c.length>1){c.shift();l=e.util.multiplyTransformMatrices(l,c[0])}return l}}();function m(t,e){var i,r;t.replace(/;\s*$/,"").split(";").forEach(function(t){var s=t.split(":");i=g(s[0].trim().toLowerCase());r=p(i,s[1].trim());e[i]=r})}function b(t,e){var i,r;for(var s in t){if(typeof t[s]==="undefined"){continue}i=g(s.toLowerCase());r=p(i,t[s]);e[i]=r}}function y(t,i){var r={};for(var s in e.cssRules[i]){if(_(t,s.split(" "))){for(var n in e.cssRules[i][s]){r[n]=e.cssRules[i][s][n]}}}return r}function _(t,e){var i,r=true;i=S(t,e.pop());if(i&&e.length){r=x(t,e)}return i&&r&&e.length===0}function x(t,e){var i,r=true;while(t.parentNode&&t.parentNode.nodeType===1&&e.length){if(r){i=e.pop()}t=t.parentNode;r=S(t,i)}return e.length===0}function S(t,e){var i=t.nodeName,r=t.getAttribute("class"),s=t.getAttribute("id"),n;n=new RegExp("^"+i,"i");e=e.replace(n,"");if(s&&e.length){n=new RegExp("#"+s+"(?![a-zA-Z\\-]+)","i");e=e.replace(n,"")}if(r&&e.length){r=r.split(" ");for(var o=r.length;o--;){n=new RegExp("\\."+r[o]+"(?![a-zA-Z\\-]+)","i");e=e.replace(n,"")}}return e.length===0}function C(t,e){var i;t.getElementById&&(i=t.getElementById(e));if(i){return i}var r,s,n=t.getElementsByTagName("*");for(s=0;s<n.length;s++){r=n[s];if(e===r.getAttribute("id")){return r}}}function w(t){var e=t.getElementsByTagName("use"),i=0;while(e.length&&i<e.length){var r=e[i],s=r.getAttribute("xlink:href").substr(1),n=r.getAttribute("x")||0,o=r.getAttribute("y")||0,a=C(t,s).cloneNode(true),h=(a.getAttribute("transform")||"")+" translate("+n+", "+o+")",c,l=e.length,f,u,d,g;T(a);if(/^svg$/i.test(a.nodeName)){var p=a.ownerDocument.createElement("g");for(u=0,d=a.attributes,g=d.length;u<g;u++){f=d.item(u);p.setAttribute(f.nodeName,f.nodeValue)}while(a.firstChild!=null){p.appendChild(a.firstChild)}a=p}for(u=0,d=r.attributes,g=d.length;u<g;u++){
f=d.item(u);if(f.nodeName==="x"||f.nodeName==="y"||f.nodeName==="xlink:href"){continue}if(f.nodeName==="transform"){h=f.nodeValue+" "+h}else{a.setAttribute(f.nodeName,f.nodeValue)}}a.setAttribute("transform",h);a.setAttribute("instantiated_by_use","1");a.removeAttribute("id");c=r.parentNode;c.replaceChild(a,r);if(e.length===l){i++}}}var O=new RegExp("^"+"\\s*("+e.reNum+"+)\\s*,?"+"\\s*("+e.reNum+"+)\\s*,?"+"\\s*("+e.reNum+"+)\\s*,?"+"\\s*("+e.reNum+"+)\\s*"+"$");function T(t){var i=t.getAttribute("viewBox"),r=1,s=1,n=0,a=0,h,l,f,u,d=t.getAttribute("width"),g=t.getAttribute("height"),p=t.getAttribute("x")||0,v=t.getAttribute("y")||0,m=t.getAttribute("preserveAspectRatio")||"",b=!i||!c.test(t.tagName)||!(i=i.match(O)),y=!d||!g||d==="100%"||g==="100%",_=b&&y,x={},S="";x.width=0;x.height=0;x.toBeParsed=_;if(_){return x}if(b){x.width=o(d);x.height=o(g);return x}n=-parseFloat(i[1]),a=-parseFloat(i[2]),h=parseFloat(i[3]),l=parseFloat(i[4]);if(!y){x.width=o(d);x.height=o(g);r=x.width/h;s=x.height/l}else{x.width=h;x.height=l}m=e.util.parsePreserveAspectRatioAttribute(m);if(m.alignX!=="none"){s=r=r>s?s:r}if(r===1&&s===1&&n===0&&a===0&&p===0&&v===0){return x}if(p||v){S=" translate("+o(p)+" "+o(v)+") "}f=S+" matrix("+r+" 0"+" 0 "+s+" "+n*r+" "+a*s+") ";if(t.tagName==="svg"){u=t.ownerDocument.createElement("g");while(t.firstChild!=null){u.appendChild(t.firstChild)}t.appendChild(u)}else{u=t;f=u.getAttribute("transform")+f}u.setAttribute("transform",f);return x}e.parseSVGDocument=function(){function t(t,e){while(t&&(t=t.parentNode)){if(e.test(t.nodeName)&&!t.getAttribute("instantiated_by_use")){return true}}return false}return function(i,r,n){if(!i){return}w(i);var o=new Date,a=e.Object.__uid++,c=T(i),f=e.util.toArray(i.getElementsByTagName("*"));c.svgUid=a;if(f.length===0&&e.isLikelyNode){f=i.selectNodes('//*[name(.)!="svg"]');var u=[];for(var d=0,g=f.length;d<g;d++){u[d]=f[d]}f=u}var p=f.filter(function(e){T(e);return h.test(e.tagName)&&!t(e,l)});if(!p||p&&!p.length){r&&r([],{});return}e.gradientDefs[a]=e.getGradientDefs(i);e.cssRules[a]=e.getCSSRules(i);e.parseElements(p,function(t){e.documentParsingTime=new Date-o;if(r){r(t,c)}},s(c),n)}}();var k={has:function(t,e){e(false)},get:function(){},set:function(){}};function j(t){var i=t.objects,s=t.options;i=i.map(function(t){return e[r(t.type)].fromObject(t)});return{objects:i,options:s}}function A(t,e,i){if(e[i]&&e[i].toSVG){t.push('	<pattern x="0" y="0" id="',i,'Pattern" ','width="',e[i].source.width,'" height="',e[i].source.height,'" patternUnits="userSpaceOnUse">\n','		<image x="0" y="0" ','width="',e[i].source.width,'" height="',e[i].source.height,'" xlink:href="',e[i].source.src,'"></image>\n	</pattern>\n')}}var M=new RegExp("(normal|italic)?\\s*(normal|small-caps)?\\s*"+"(normal|bold|bolder|lighter|100|200|300|400|500|600|700|800|900)?\\s*("+e.reNum+"(?:px|cm|mm|em|pt|pc|in)*)(?:\\/(normal|"+e.reNum+"))?\\s+(.*)");i(e,{parseFontDeclaration:function(t,e){var i=t.match(M);if(!i){return}var r=i[1],s=i[3],n=i[4],a=i[5],h=i[6];if(r){e.fontStyle=r}if(s){e.fontWeight=isNaN(parseFloat(s))?s:parseFloat(s)}if(n){e.fontSize=o(n)}if(h){e.fontFamily=h}if(a){e.lineHeight=a==="normal"?1:a}},getGradientDefs:function(t){var e=t.getElementsByTagName("linearGradient"),i=t.getElementsByTagName("radialGradient"),r,s,n=0,o,a,h=[],c={},l={};h.length=e.length+i.length;s=e.length;while(s--){h[n++]=e[s]}s=i.length;while(s--){h[n++]=i[s]}while(n--){r=h[n];a=r.getAttribute("xlink:href");o=r.getAttribute("id");if(a){l[o]=a.substr(1)}c[o]=r}for(o in l){var f=c[l[o]].cloneNode(true);r=c[o];while(f.firstChild){r.appendChild(f.firstChild)}}return c},parseAttributes:function(t,r,s){if(!t){return}var n,o={},a;if(typeof s==="undefined"){s=t.getAttribute("svgUid")}if(t.parentNode&&f.test(t.parentNode.nodeName)){o=e.parseAttributes(t.parentNode,r,s)}a=o&&o.fontSize||t.getAttribute("font-size")||e.Text.DEFAULT_SVG_FONT_SIZE;var h=r.reduce(function(e,i){n=t.getAttribute(i);if(n){i=g(i);n=p(i,n,o,a);e[i]=n}return e},{});h=i(h,i(y(t,s),e.parseStyleAttribute(t)));if(h.font){e.parseFontDeclaration(h.font,h)}return v(i(o,h))},parseElements:function(t,i,r,s){new e.ElementsParser(t,i,r,s).parse()},parseStyleAttribute:function(t){var e={},i=t.getAttribute("style");if(!i){return e}if(typeof i==="string"){m(i,e)}else{b(i,e)}return e},parsePointsAttribute:function(t){if(!t){return null}t=t.replace(/,/g," ").trim();t=t.split(/\s+/);var e=[],i,r;i=0;r=t.length;for(;i<r;i+=2){e.push({x:parseFloat(t[i]),y:parseFloat(t[i+1])})}return e},getCSSRules:function(t){var i=t.getElementsByTagName("style"),r={},s;for(var n=0,o=i.length;n<o;n++){var a=i[n].textContent||i[n].text;a=a.replace(/\/\*[\s\S]*?\*\//g,"");if(a.trim()===""){continue}s=a.match(/[^{]*\{[\s\S]*?\}/g);s=s.map(function(t){return t.trim()});s.forEach(function(t){var i=t.match(/([\s\S]*?)\s*\{([^}]*)\}/),s={},n=i[2].trim(),o=n.replace(/;$/,"").split(/\s*;\s*/);for(var a=0,h=o.length;a<h;a++){var c=o[a].split(/\s*:\s*/),l=g(c[0]),f=p(l,c[1],c[0]);s[l]=f}t=i[1];t.split(",").forEach(function(t){t=t.replace(/^svg/i,"").trim();if(t===""){return}r[t]=e.util.object.clone(s)})})}return r},loadSVGFromURL:function(t,i,r){t=t.replace(/^\n\s*/,"").trim();k.has(t,function(r){if(r){k.get(t,function(t){var e=j(t);i(e.objects,e.options)})}else{new e.util.request(t,{method:"get",onComplete:s})}});function s(s){var n=s.responseXML;if(n&&!n.documentElement&&e.window.ActiveXObject&&s.responseText){n=new ActiveXObject("Microsoft.XMLDOM");n.async="false";n.loadXML(s.responseText.replace(/<!DOCTYPE[\s\S]*?(\[[\s\S]*\])*?>/i,""))}if(!n||!n.documentElement){return}e.parseSVGDocument(n.documentElement,function(r,s){k.set(t,{objects:e.util.array.invoke(r,"toObject"),options:s});i(r,s)},r)}},loadSVGFromString:function(t,i,r){t=t.trim();var s;if(typeof DOMParser!=="undefined"){var n=new DOMParser;if(n&&n.parseFromString){s=n.parseFromString(t,"text/xml")}}else if(e.window.ActiveXObject){s=new ActiveXObject("Microsoft.XMLDOM");s.async="false";s.loadXML(t.replace(/<!DOCTYPE[\s\S]*?(\[[\s\S]*\])*?>/i,""))}e.parseSVGDocument(s.documentElement,function(t,e){i(t,e)},r)},createSVGFontFacesMarkup:function(t){var i="",r={},s,n,o,a,h,c,l,f=e.fontPaths;for(var u=0,d=t.length;u<d;u++){s=t[u];n=s.fontFamily;if(s.type.indexOf("text")===-1||r[n]||!f[n]){continue}r[n]=true;if(!s.styles){continue}o=s.styles;for(h in o){a=o[h];for(l in a){c=a[l];n=c.fontFamily;if(!r[n]&&f[n]){r[n]=true}}}}for(var g in r){i+=["		@font-face {\n","			font-family: '",g,"';\n","			src: url('",f[g],"');\n","		}\n"].join("")}if(i){i=['	<style type="text/css">',"<![CDATA[\n",i,"]]>","</style>\n"].join("")}return i},createSVGRefElementsMarkup:function(t){var e=[];A(e,t,"backgroundColor");A(e,t,"overlayColor");return e.join("")}})})(typeof exports!=="undefined"?exports:this);fabric.ElementsParser=function(t,e,i,r){this.elements=t;this.callback=e;this.options=i;this.reviver=r;this.svgUid=i&&i.svgUid||0};fabric.ElementsParser.prototype.parse=function(){this.instances=new Array(this.elements.length);this.numElements=this.elements.length;this.createObjects()};fabric.ElementsParser.prototype.createObjects=function(){for(var t=0,e=this.elements.length;t<e;t++){this.elements[t].setAttribute("svgUid",this.svgUid);(function(t,e){setTimeout(function(){t.createObject(t.elements[e],e)},0)})(this,t)}};fabric.ElementsParser.prototype.createObject=function(t,e){var i=fabric[fabric.util.string.capitalize(t.tagName)];if(i&&i.fromElement){try{this._createObject(i,t,e)}catch(r){fabric.log(r)}}else{this.checkIfDone()}};fabric.ElementsParser.prototype._createObject=function(t,e,i){if(t.async){t.fromElement(e,this.createCallback(i,e),this.options)}else{var r=t.fromElement(e,this.options);this.resolveGradient(r,"fill");this.resolveGradient(r,"stroke");this.reviver&&this.reviver(e,r);this.instances[i]=r;this.checkIfDone()}};fabric.ElementsParser.prototype.createCallback=function(t,e){var i=this;return function(r){i.resolveGradient(r,"fill");i.resolveGradient(r,"stroke");i.reviver&&i.reviver(e,r);i.instances[t]=r;i.checkIfDone()}};fabric.ElementsParser.prototype.resolveGradient=function(t,e){var i=t.get(e);if(!/^url\(/.test(i)){return}var r=i.slice(5,i.length-1);if(fabric.gradientDefs[this.svgUid][r]){t.set(e,fabric.Gradient.fromElement(fabric.gradientDefs[this.svgUid][r],t))}};fabric.ElementsParser.prototype.checkIfDone=function(){if(--this.numElements===0){this.instances=this.instances.filter(function(t){return t!=null});this.callback(this.instances)}};(function(t){"use strict";var e=t.fabric||(t.fabric={});if(e.Point){e.warn("fabric.Point is already defined");return}e.Point=i;function i(t,e){this.x=t;this.y=e}i.prototype={constructor:i,add:function(t){return new i(this.x+t.x,this.y+t.y)},addEquals:function(t){this.x+=t.x;this.y+=t.y;return this},scalarAdd:function(t){return new i(this.x+t,this.y+t)},scalarAddEquals:function(t){this.x+=t;this.y+=t;return this},subtract:function(t){return new i(this.x-t.x,this.y-t.y)},subtractEquals:function(t){this.x-=t.x;this.y-=t.y;return this},scalarSubtract:function(t){return new i(this.x-t,this.y-t)},scalarSubtractEquals:function(t){this.x-=t;this.y-=t;return this},multiply:function(t){return new i(this.x*t,this.y*t)},multiplyEquals:function(t){this.x*=t;this.y*=t;return this},divide:function(t){return new i(this.x/t,this.y/t)},divideEquals:function(t){this.x/=t;this.y/=t;return this},eq:function(t){return this.x===t.x&&this.y===t.y},lt:function(t){return this.x<t.x&&this.y<t.y},lte:function(t){return this.x<=t.x&&this.y<=t.y},gt:function(t){return this.x>t.x&&this.y>t.y},gte:function(t){return this.x>=t.x&&this.y>=t.y},lerp:function(t,e){return new i(this.x+(t.x-this.x)*e,this.y+(t.y-this.y)*e)},distanceFrom:function(t){var e=this.x-t.x,i=this.y-t.y;return Math.sqrt(e*e+i*i)},midPointFrom:function(t){return new i(this.x+(t.x-this.x)/2,this.y+(t.y-this.y)/2)},min:function(t){return new i(Math.min(this.x,t.x),Math.min(this.y,t.y))},max:function(t){return new i(Math.max(this.x,t.x),Math.max(this.y,t.y))},toString:function(){return this.x+","+this.y},setXY:function(t,e){this.x=t;this.y=e},setFromPoint:function(t){this.x=t.x;this.y=t.y},swap:function(t){var e=this.x,i=this.y;this.x=t.x;this.y=t.y;t.x=e;t.y=i}}})(typeof exports!=="undefined"?exports:this);(function(t){"use strict";var e=t.fabric||(t.fabric={});if(e.Intersection){e.warn("fabric.Intersection is already defined");return}function i(t){this.status=t;this.points=[]}e.Intersection=i;e.Intersection.prototype={appendPoint:function(t){this.points.push(t)},appendPoints:function(t){this.points=this.points.concat(t)}};e.Intersection.intersectLineLine=function(t,r,s,n){var o,a=(n.x-s.x)*(t.y-s.y)-(n.y-s.y)*(t.x-s.x),h=(r.x-t.x)*(t.y-s.y)-(r.y-t.y)*(t.x-s.x),c=(n.y-s.y)*(r.x-t.x)-(n.x-s.x)*(r.y-t.y);if(c!==0){var l=a/c,f=h/c;if(0<=l&&l<=1&&0<=f&&f<=1){o=new i("Intersection");o.points.push(new e.Point(t.x+l*(r.x-t.x),t.y+l*(r.y-t.y)))}else{o=new i}}else{if(a===0||h===0){o=new i("Coincident")}else{o=new i("Parallel")}}return o};e.Intersection.intersectLinePolygon=function(t,e,r){var s=new i,n=r.length;for(var o=0;o<n;o++){var a=r[o],h=r[(o+1)%n],c=i.intersectLineLine(t,e,a,h);s.appendPoints(c.points)}if(s.points.length>0){s.status="Intersection"}return s};e.Intersection.intersectPolygonPolygon=function(t,e){var r=new i,s=t.length;for(var n=0;n<s;n++){var o=t[n],a=t[(n+1)%s],h=i.intersectLinePolygon(o,a,e);r.appendPoints(h.points)}if(r.points.length>0){r.status="Intersection"}return r};e.Intersection.intersectPolygonRectangle=function(t,r,s){var n=r.min(s),o=r.max(s),a=new e.Point(o.x,n.y),h=new e.Point(n.x,o.y),c=i.intersectLinePolygon(n,a,t),l=i.intersectLinePolygon(a,o,t),f=i.intersectLinePolygon(o,h,t),u=i.intersectLinePolygon(h,n,t),d=new i;d.appendPoints(c.points);d.appendPoints(l.points);d.appendPoints(f.points);d.appendPoints(u.points);if(d.points.length>0){d.status="Intersection"}return d}})(typeof exports!=="undefined"?exports:this);(function(t){"use strict";var e=t.fabric||(t.fabric={});if(e.Color){e.warn("fabric.Color is already defined.");return}function i(t){if(!t){this.setSource([0,0,0,1])}else{this._tryParsingColor(t)}}e.Color=i;e.Color.prototype={_tryParsingColor:function(t){var e;if(t in i.colorNameMap){t=i.colorNameMap[t]}if(t==="transparent"){e=[255,255,255,0]}if(!e){e=i.sourceFromHex(t)}if(!e){e=i.sourceFromRgb(t)}if(!e){e=i.sourceFromHsl(t)}if(!e){e=[0,0,0,1]}if(e){this.setSource(e)}},_rgbToHsl:function(t,i,r){t/=255,i/=255,r/=255;var s,n,o,a=e.util.array.max([t,i,r]),h=e.util.array.min([t,i,r]);o=(a+h)/2;if(a===h){s=n=0}else{var c=a-h;n=o>.5?c/(2-a-h):c/(a+h);switch(a){case t:s=(i-r)/c+(i<r?6:0);break;case i:s=(r-t)/c+2;break;case r:s=(t-i)/c+4;break}s/=6}return[Math.round(s*360),Math.round(n*100),Math.round(o*100)]},getSource:function(){return this._source},setSource:function(t){this._source=t},toRgb:function(){var t=this.getSource();return"rgb("+t[0]+","+t[1]+","+t[2]+")"},toRgba:function(){var t=this.getSource();return"rgba("+t[0]+","+t[1]+","+t[2]+","+t[3]+")"},toHsl:function(){var t=this.getSource(),e=this._rgbToHsl(t[0],t[1],t[2]);return"hsl("+e[0]+","+e[1]+"%,"+e[2]+"%)"},toHsla:function(){var t=this.getSource(),e=this._rgbToHsl(t[0],t[1],t[2]);return"hsla("+e[0]+","+e[1]+"%,"+e[2]+"%,"+t[3]+")"},toHex:function(){var t=this.getSource(),e,i,r;e=t[0].toString(16);e=e.length===1?"0"+e:e;i=t[1].toString(16);i=i.length===1?"0"+i:i;r=t[2].toString(16);r=r.length===1?"0"+r:r;return e.toUpperCase()+i.toUpperCase()+r.toUpperCase()},getAlpha:function(){return this.getSource()[3]},setAlpha:function(t){var e=this.getSource();e[3]=t;this.setSource(e);return this},toGrayscale:function(){var t=this.getSource(),e=parseInt((t[0]*.3+t[1]*.59+t[2]*.11).toFixed(0),10),i=t[3];this.setSource([e,e,e,i]);return this},toBlackWhite:function(t){var e=this.getSource(),i=(e[0]*.3+e[1]*.59+e[2]*.11).toFixed(0),r=e[3];t=t||127;i=Number(i)<Number(t)?0:255;this.setSource([i,i,i,r]);return this},overlayWith:function(t){if(!(t instanceof i)){t=new i(t)}var e=[],r=this.getAlpha(),s=.5,n=this.getSource(),o=t.getSource();for(var a=0;a<3;a++){e.push(Math.round(n[a]*(1-s)+o[a]*s))}e[3]=r;this.setSource(e);return this}};e.Color.reRGBa=/^rgba?\(\s*(\d{1,3}(?:\.\d+)?\%?)\s*,\s*(\d{1,3}(?:\.\d+)?\%?)\s*,\s*(\d{1,3}(?:\.\d+)?\%?)\s*(?:\s*,\s*(\d+(?:\.\d+)?)\s*)?\)$/;e.Color.reHSLa=/^hsla?\(\s*(\d{1,3})\s*,\s*(\d{1,3}\%)\s*,\s*(\d{1,3}\%)\s*(?:\s*,\s*(\d+(?:\.\d+)?)\s*)?\)$/;e.Color.reHex=/^#?([0-9a-f]{6}|[0-9a-f]{3})$/i;e.Color.colorNameMap={aqua:"#00FFFF",black:"#000000",blue:"#0000FF",fuchsia:"#FF00FF",gray:"#808080",grey:"#808080",green:"#008000",lime:"#00FF00",maroon:"#800000",navy:"#000080",olive:"#808000",orange:"#FFA500",purple:"#800080",red:"#FF0000",silver:"#C0C0C0",teal:"#008080",white:"#FFFFFF",yellow:"#FFFF00"};function r(t,e,i){if(i<0){i+=1}if(i>1){i-=1}if(i<1/6){return t+(e-t)*6*i}if(i<1/2){return e}if(i<2/3){return t+(e-t)*(2/3-i)*6}return t}e.Color.fromRgb=function(t){return i.fromSource(i.sourceFromRgb(t))};e.Color.sourceFromRgb=function(t){var e=t.match(i.reRGBa);if(e){var r=parseInt(e[1],10)/(/%$/.test(e[1])?100:1)*(/%$/.test(e[1])?255:1),s=parseInt(e[2],10)/(/%$/.test(e[2])?100:1)*(/%$/.test(e[2])?255:1),n=parseInt(e[3],10)/(/%$/.test(e[3])?100:1)*(/%$/.test(e[3])?255:1);return[parseInt(r,10),parseInt(s,10),parseInt(n,10),e[4]?parseFloat(e[4]):1]}};e.Color.fromRgba=i.fromRgb;e.Color.fromHsl=function(t){return i.fromSource(i.sourceFromHsl(t))};e.Color.sourceFromHsl=function(t){var e=t.match(i.reHSLa);if(!e){return}var s=(parseFloat(e[1])%360+360)%360/360,n=parseFloat(e[2])/(/%$/.test(e[2])?100:1),o=parseFloat(e[3])/(/%$/.test(e[3])?100:1),a,h,c;if(n===0){a=h=c=o}else{var l=o<=.5?o*(n+1):o+n-o*n,f=o*2-l;a=r(f,l,s+1/3);h=r(f,l,s);c=r(f,l,s-1/3)}return[Math.round(a*255),Math.round(h*255),Math.round(c*255),e[4]?parseFloat(e[4]):1]};e.Color.fromHsla=i.fromHsl;e.Color.fromHex=function(t){return i.fromSource(i.sourceFromHex(t))};e.Color.sourceFromHex=function(t){if(t.match(i.reHex)){var e=t.slice(t.indexOf("#")+1),r=e.length===3,s=r?e.charAt(0)+e.charAt(0):e.substring(0,2),n=r?e.charAt(1)+e.charAt(1):e.substring(2,4),o=r?e.charAt(2)+e.charAt(2):e.substring(4,6);return[parseInt(s,16),parseInt(n,16),parseInt(o,16),1]}};e.Color.fromSource=function(t){var e=new i;e.setSource(t);return e}})(typeof exports!=="undefined"?exports:this);(function(){function t(t){var e=t.getAttribute("style"),i=t.getAttribute("offset")||0,r,s,n;i=parseFloat(i)/(/%$/.test(i)?100:1);i=i<0?0:i>1?1:i;if(e){var o=e.split(/\s*;\s*/);if(o[o.length-1]===""){o.pop()}for(var a=o.length;a--;){var h=o[a].split(/\s*:\s*/),c=h[0].trim(),l=h[1].trim();if(c==="stop-color"){r=l}else if(c==="stop-opacity"){n=l}}}if(!r){r=t.getAttribute("stop-color")||"rgb(0,0,0)"}if(!n){n=t.getAttribute("stop-opacity")}r=new fabric.Color(r);s=r.getAlpha();n=isNaN(parseFloat(n))?1:parseFloat(n);n*=s;return{offset:i,color:r.toRgb(),opacity:n}}function e(t){return{x1:t.getAttribute("x1")||0,y1:t.getAttribute("y1")||0,x2:t.getAttribute("x2")||"100%",y2:t.getAttribute("y2")||0}}function i(t){return{x1:t.getAttribute("fx")||t.getAttribute("cx")||"50%",y1:t.getAttribute("fy")||t.getAttribute("cy")||"50%",r1:0,x2:t.getAttribute("cx")||"50%",y2:t.getAttribute("cy")||"50%",r2:t.getAttribute("r")||"50%"}}fabric.Gradient=fabric.util.createClass({offsetX:0,offsetY:0,initialize:function(t){t||(t={});var e={};this.id=fabric.Object.__uid++;this.type=t.type||"linear";e={x1:t.coords.x1||0,y1:t.coords.y1||0,x2:t.coords.x2||0,y2:t.coords.y2||0};if(this.type==="radial"){e.r1=t.coords.r1||0;e.r2=t.coords.r2||0}this.coords=e;this.colorStops=t.colorStops.slice();if(t.gradientTransform){this.gradientTransform=t.gradientTransform}this.offsetX=t.offsetX||this.offsetX;this.offsetY=t.offsetY||this.offsetY},addColorStop:function(t){for(var e in t){var i=new fabric.Color(t[e]);this.colorStops.push({offset:e,color:i.toRgb(),opacity:i.getAlpha()})}return this},toObject:function(){return{type:this.type,coords:this.coords,colorStops:this.colorStops,offsetX:this.offsetX,offsetY:this.offsetY,gradientTransform:this.gradientTransform?this.gradientTransform.concat():this.gradientTransform}},toSVG:function(t){var e=fabric.util.object.clone(this.coords),i,r;this.colorStops.sort(function(t,e){return t.offset-e.offset});if(!(t.group&&t.group.type==="path-group")){for(var s in e){if(s==="x1"||s==="x2"||s==="r2"){e[s]+=this.offsetX-t.width/2}else if(s==="y1"||s==="y2"){e[s]+=this.offsetY-t.height/2}}}r='id="SVGID_'+this.id+'" gradientUnits="userSpaceOnUse"';if(this.gradientTransform){r+=' gradientTransform="matrix('+this.gradientTransform.join(" ")+')" '}if(this.type==="linear"){i=["<linearGradient ",r,' x1="',e.x1,'" y1="',e.y1,'" x2="',e.x2,'" y2="',e.y2,'">\n']}else if(this.type==="radial"){i=["<radialGradient ",r,' cx="',e.x2,'" cy="',e.y2,'" r="',e.r2,'" fx="',e.x1,'" fy="',e.y1,'">\n']}for(var n=0;n<this.colorStops.length;n++){i.push("<stop ",'offset="',this.colorStops[n].offset*100+"%",'" style="stop-color:',this.colorStops[n].color,this.colorStops[n].opacity!=null?";stop-opacity: "+this.colorStops[n].opacity:";",'"/>\n')}i.push(this.type==="linear"?"</linearGradient>\n":"</radialGradient>\n");return i.join("")},toLive:function(t,e){var i,r,s=fabric.util.object.clone(this.coords);if(!this.type){return}if(e.group&&e.group.type==="path-group"){for(r in s){if(r==="x1"||r==="x2"){s[r]+=-this.offsetX+e.width/2}else if(r==="y1"||r==="y2"){s[r]+=-this.offsetY+e.height/2}}}if(this.type==="linear"){i=t.createLinearGradient(s.x1,s.y1,s.x2,s.y2)}else if(this.type==="radial"){i=t.createRadialGradient(s.x1,s.y1,s.r1,s.x2,s.y2,s.r2)}for(var n=0,o=this.colorStops.length;n<o;n++){var a=this.colorStops[n].color,h=this.colorStops[n].opacity,c=this.colorStops[n].offset;if(typeof h!=="undefined"){a=new fabric.Color(a).setAlpha(h).toRgba()}i.addColorStop(parseFloat(c),a)}return i}});fabric.util.object.extend(fabric.Gradient,{fromElement:function(s,n){var o=s.getElementsByTagName("stop"),a=s.nodeName==="linearGradient"?"linear":"radial",h=s.getAttribute("gradientUnits")||"objectBoundingBox",c=s.getAttribute("gradientTransform"),l=[],f={},u;if(a==="linear"){f=e(s)}else if(a==="radial"){f=i(s)}for(var d=o.length;d--;){l.push(t(o[d]))}u=r(n,f,h);var g=new fabric.Gradient({type:a,coords:f,colorStops:l,offsetX:-n.left,offsetY:-n.top});if(c||u!==""){g.gradientTransform=fabric.parseTransformAttribute((c||"")+u)}return g},forObject:function(t,e){e||(e={});r(t,e.coords,"userSpaceOnUse");return new fabric.Gradient(e)}});function r(t,e,i){var r,s=0,n=1,o="";for(var a in e){r=parseFloat(e[a],10);if(typeof e[a]==="string"&&/^\d+%$/.test(e[a])){n=.01}else{n=1}if(a==="x1"||a==="x2"||a==="r2"){n*=i==="objectBoundingBox"?t.width:1;s=i==="objectBoundingBox"?t.left||0:0}else if(a==="y1"||a==="y2"){n*=i==="objectBoundingBox"?t.height:1;s=i==="objectBoundingBox"?t.top||0:0}e[a]=r*n+s}if(t.type==="ellipse"&&e.r2!==null&&i==="objectBoundingBox"&&t.rx!==t.ry){var h=t.ry/t.rx;o=" scale(1, "+h+")";if(e.y1){e.y1/=h}if(e.y2){e.y2/=h}}return o}})();fabric.Pattern=fabric.util.createClass({repeat:"repeat",offsetX:0,offsetY:0,initialize:function(t){t||(t={});this.id=fabric.Object.__uid++;if(t.source){if(typeof t.source==="string"){if(typeof fabric.util.getFunctionBody(t.source)!=="undefined"){this.source=new Function(fabric.util.getFunctionBody(t.source))}else{var e=this;this.source=fabric.util.createImage();fabric.util.loadImage(t.source,function(t){e.source=t})}}else{this.source=t.source}}if(t.repeat){this.repeat=t.repeat}if(t.offsetX){this.offsetX=t.offsetX}if(t.offsetY){this.offsetY=t.offsetY}},toObject:function(){var t;if(typeof this.source==="function"){t=String(this.source)}else if(typeof this.source.src==="string"){t=this.source.src}else if(typeof this.source==="object"&&this.source.toDataURL){t=this.source.toDataURL()}return{source:t,repeat:this.repeat,offsetX:this.offsetX,offsetY:this.offsetY}},toSVG:function(t){var e=typeof this.source==="function"?this.source():this.source,i=e.width/t.getWidth(),r=e.height/t.getHeight(),s=this.offsetX/t.getWidth(),n=this.offsetY/t.getHeight(),o="";if(this.repeat==="repeat-x"||this.repeat==="no-repeat"){r=1}if(this.repeat==="repeat-y"||this.repeat==="no-repeat"){i=1}if(e.src){o=e.src}else if(e.toDataURL){o=e.toDataURL()}return'<pattern id="SVGID_'+this.id+'" x="'+s+'" y="'+n+'" width="'+i+'" height="'+r+'">\n'+'<image x="0" y="0"'+' width="'+e.width+'" height="'+e.height+'" xlink:href="'+o+'"></image>\n'+"</pattern>\n"},toLive:function(t){var e=typeof this.source==="function"?this.source():this.source;if(!e){return""}if(typeof e.src!=="undefined"){if(!e.complete){return""}if(e.naturalWidth===0||e.naturalHeight===0){return""}}return t.createPattern(e,this.repeat)}});(function(t){"use strict";var e=t.fabric||(t.fabric={}),i=e.util.toFixed;if(e.Shadow){e.warn("fabric.Shadow is already defined.");return}e.Shadow=e.util.createClass({color:"rgb(0,0,0)",blur:0,offsetX:0,offsetY:0,affectStroke:false,includeDefaultValues:true,initialize:function(t){if(typeof t==="string"){t=this._parseShadow(t)}for(var i in t){this[i]=t[i]}this.id=e.Object.__uid++},_parseShadow:function(t){var i=t.trim(),r=e.Shadow.reOffsetsAndBlur.exec(i)||[],s=i.replace(e.Shadow.reOffsetsAndBlur,"")||"rgb(0,0,0)";return{color:s.trim(),offsetX:parseInt(r[1],10)||0,offsetY:parseInt(r[2],10)||0,blur:parseInt(r[3],10)||0}},toString:function(){return[this.offsetX,this.offsetY,this.blur,this.color].join("px ")},toSVG:function(t){var r=40,s=40,n=e.Object.NUM_FRACTION_DIGITS,o=e.util.rotateVector({x:this.offsetX,y:this.offsetY},e.util.degreesToRadians(-t.angle)),a=20;if(t.width&&t.height){r=i((Math.abs(o.x)+this.blur)/t.width,n)*100+a;s=i((Math.abs(o.y)+this.blur)/t.height,n)*100+a}if(t.flipX){o.x*=-1}if(t.flipY){o.y*=-1}return'<filter id="SVGID_'+this.id+'" y="-'+s+'%" height="'+(100+2*s)+'%" '+'x="-'+r+'%" width="'+(100+2*r)+'%" '+">\n"+'	<feGaussianBlur in="SourceAlpha" stdDeviation="'+i(this.blur?this.blur/2:0,n)+'"></feGaussianBlur>\n'+'	<feOffset dx="'+i(o.x,n)+'" dy="'+i(o.y,n)+'" result="oBlur" ></feOffset>\n'+'	<feFlood flood-color="'+this.color+'"/>\n'+'	<feComposite in2="oBlur" operator="in" />\n'+"	<feMerge>\n"+"		<feMergeNode></feMergeNode>\n"+'		<feMergeNode in="SourceGraphic"></feMergeNode>\n'+"	</feMerge>\n"+"</filter>\n"},toObject:function(){if(this.includeDefaultValues){return{color:this.color,blur:this.blur,offsetX:this.offsetX,offsetY:this.offsetY,affectStroke:this.affectStroke}}var t={},i=e.Shadow.prototype;["color","blur","offsetX","offsetY","affectStroke"].forEach(function(e){if(this[e]!==i[e]){t[e]=this[e]}},this);return t}});e.Shadow.reOffsetsAndBlur=/(?:\s|^)(-?\d+(?:px)?(?:\s?|$))?(-?\d+(?:px)?(?:\s?|$))?(\d+(?:px)?)?(?:\s?|$)(?:$|\s)/})(typeof exports!=="undefined"?exports:this);(function(){"use strict";if(fabric.StaticCanvas){fabric.warn("fabric.StaticCanvas is already defined.");return}var t=fabric.util.object.extend,e=fabric.util.getElementOffset,i=fabric.util.removeFromArray,r=fabric.util.toFixed,s=new Error("Could not initialize `canvas` element");fabric.StaticCanvas=fabric.util.createClass({initialize:function(t,e){e||(e={});this._initStatic(t,e)},backgroundColor:"",backgroundImage:null,overlayColor:"",overlayImage:null,includeDefaultValues:true,stateful:true,renderOnAddRemove:true,clipTo:null,controlsAboveOverlay:false,allowTouchScrolling:false,imageSmoothingEnabled:true,preserveObjectStacking:false,viewportTransform:[1,0,0,1,0,0],onBeforeScaleRotate:function(){},enableRetinaScaling:true,_initStatic:function(t,e){this._objects=[];this._createLowerCanvas(t);this._initOptions(e);this._setImageSmoothing();if(!this.interactive){this._initRetinaScaling()}if(e.overlayImage){this.setOverlayImage(e.overlayImage,this.renderAll.bind(this))}if(e.backgroundImage){this.setBackgroundImage(e.backgroundImage,this.renderAll.bind(this))}if(e.backgroundColor){this.setBackgroundColor(e.backgroundColor,this.renderAll.bind(this))}if(e.overlayColor){this.setOverlayColor(e.overlayColor,this.renderAll.bind(this))}this.calcOffset()},_isRetinaScaling:function(){return fabric.devicePixelRatio!==1&&this.enableRetinaScaling},_initRetinaScaling:function(){if(!this._isRetinaScaling()){return}this.lowerCanvasEl.setAttribute("width",this.width*fabric.devicePixelRatio);this.lowerCanvasEl.setAttribute("height",this.height*fabric.devicePixelRatio);this.contextContainer.scale(fabric.devicePixelRatio,fabric.devicePixelRatio)},calcOffset:function(){this._offset=e(this.lowerCanvasEl);return this},setOverlayImage:function(t,e,i){return this.__setBgOverlayImage("overlayImage",t,e,i)},setBackgroundImage:function(t,e,i){return this.__setBgOverlayImage("backgroundImage",t,e,i)},setOverlayColor:function(t,e){return this.__setBgOverlayColor("overlayColor",t,e)},setBackgroundColor:function(t,e){return this.__setBgOverlayColor("backgroundColor",t,e)},_setImageSmoothing:function(){var t=this.getContext();t.imageSmoothingEnabled=t.imageSmoothingEnabled||t.webkitImageSmoothingEnabled||t.mozImageSmoothingEnabled||t.msImageSmoothingEnabled||t.oImageSmoothingEnabled;t.imageSmoothingEnabled=this.imageSmoothingEnabled},__setBgOverlayImage:function(t,e,i,r){if(typeof e==="string"){fabric.util.loadImage(e,function(e){this[t]=new fabric.Image(e,r);i&&i(e)},this,r&&r.crossOrigin)}else{r&&e.setOptions(r);this[t]=e;i&&i(e)}return this},__setBgOverlayColor:function(t,e,i){if(e&&e.source){var r=this;fabric.util.loadImage(e.source,function(s){r[t]=new fabric.Pattern({source:s,repeat:e.repeat,offsetX:e.offsetX,offsetY:e.offsetY});i&&i()})}else{this[t]=e;i&&i()}return this},_createCanvasElement:function(){var t=fabric.document.createElement("canvas");if(!t.style){t.style={}}if(!t){throw s}this._initCanvasElement(t);return t},_initCanvasElement:function(t){fabric.util.createCanvasElement(t);if(typeof t.getContext==="undefined"){throw s}},_initOptions:function(t){for(var e in t){this[e]=t[e]}this.width=this.width||parseInt(this.lowerCanvasEl.width,10)||0;this.height=this.height||parseInt(this.lowerCanvasEl.height,10)||0;if(!this.lowerCanvasEl.style){return}this.lowerCanvasEl.width=this.width;this.lowerCanvasEl.height=this.height;this.lowerCanvasEl.style.width=this.width+"px";this.lowerCanvasEl.style.height=this.height+"px";this.viewportTransform=this.viewportTransform.slice()},_createLowerCanvas:function(t){this.lowerCanvasEl=fabric.util.getById(t)||this._createCanvasElement();this._initCanvasElement(this.lowerCanvasEl);fabric.util.addClass(this.lowerCanvasEl,"lower-canvas");if(this.interactive){this._applyCanvasStyle(this.lowerCanvasEl)}this.contextContainer=this.lowerCanvasEl.getContext("2d")},getWidth:function(){return this.width},getHeight:function(){return this.height},setWidth:function(t,e){return this.setDimensions({width:t},e)},setHeight:function(t,e){return this.setDimensions({height:t},e)},setDimensions:function(t,e){var i;e=e||{};for(var r in t){i=t[r];if(!e.cssOnly){this._setBackstoreDimension(r,t[r]);i+="px"}if(!e.backstoreOnly){this._setCssDimension(r,i)}}this._initRetinaScaling();this._setImageSmoothing();this.calcOffset();if(!e.cssOnly){this.renderAll()}return this},_setBackstoreDimension:function(t,e){this.lowerCanvasEl[t]=e;if(this.upperCanvasEl){this.upperCanvasEl[t]=e}if(this.cacheCanvasEl){this.cacheCanvasEl[t]=e}this[t]=e;return this},_setCssDimension:function(t,e){this.lowerCanvasEl.style[t]=e;if(this.upperCanvasEl){this.upperCanvasEl.style[t]=e}if(this.wrapperEl){this.wrapperEl.style[t]=e}return this},getZoom:function(){return Math.sqrt(this.viewportTransform[0]*this.viewportTransform[3])},setViewportTransform:function(t){var e=this.getActiveGroup();this.viewportTransform=t;this.renderAll();for(var i=0,r=this._objects.length;i<r;i++){this._objects[i].setCoords()}if(e){e.setCoords()}return this},zoomToPoint:function(t,e){var i=t;t=fabric.util.transformPoint(t,fabric.util.invertTransform(this.viewportTransform));this.viewportTransform[0]=e;this.viewportTransform[3]=e;var r=fabric.util.transformPoint(t,this.viewportTransform);this.viewportTransform[4]+=i.x-r.x;this.viewportTransform[5]+=i.y-r.y;this.renderAll();for(var s=0,n=this._objects.length;s<n;s++){this._objects[s].setCoords()}return this},setZoom:function(t){this.zoomToPoint(new fabric.Point(0,0),t);return this},absolutePan:function(t){this.viewportTransform[4]=-t.x;this.viewportTransform[5]=-t.y;this.renderAll();for(var e=0,i=this._objects.length;e<i;e++){this._objects[e].setCoords()}return this},relativePan:function(t){return this.absolutePan(new fabric.Point(-t.x-this.viewportTransform[4],-t.y-this.viewportTransform[5]))},getElement:function(){return this.lowerCanvasEl},getActiveObject:function(){return null},getActiveGroup:function(){return null},_onObjectAdded:function(t){this.stateful&&t.setupState();t._set("canvas",this);t.setCoords();this.fire("object:added",{target:t});t.fire("added")},_onObjectRemoved:function(t){if(this.getActiveObject()===t){this.fire("before:selection:cleared",{target:t});this._discardActiveObject();this.fire("selection:cleared")}this.fire("object:removed",{target:t});t.fire("removed")},clearContext:function(t){t.clearRect(0,0,this.width,this.height);return this},getContext:function(){return this.contextContainer},clear:function(){this._objects.length=0;if(this.discardActiveGroup){this.discardActiveGroup()}if(this.discardActiveObject){this.discardActiveObject()}this.clearContext(this.contextContainer);if(this.contextTop){this.clearContext(this.contextTop)}this.fire("canvas:cleared");this.renderAll();return this},_chooseObjectsToRender:function(){var t=this.getActiveGroup(),e,i=[],r=[];if(t&&!this.preserveObjectStacking){for(var s=0,n=this._objects.length;s<n;s++){e=this._objects[s];if(!t.contains(e)){i.push(e)}else{r.push(e)}}t._set("_objects",r)}else{i=this._objects}return i},renderAll:function(){var t=this.contextContainer,e;if(this.contextTop&&this.selection&&!this._groupSelector&&!this.isDrawingMode){this.clearContext(this.contextTop)}this.clearContext(t);this.fire("before:render");if(this.clipTo){fabric.util.clipContext(this,t)}this._renderBackground(t);t.save();e=this._chooseObjectsToRender();t.transform.apply(t,this.viewportTransform);

this._renderObjects(t,e);this.preserveObjectStacking||this._renderObjects(t,[this.getActiveGroup()]);t.restore();if(!this.controlsAboveOverlay&&this.interactive){this.drawControls(t)}if(this.clipTo){t.restore()}this._renderOverlay(t);if(this.controlsAboveOverlay&&this.interactive){this.drawControls(t)}this.fire("after:render");return this},_renderObjects:function(t,e){for(var i=0,r=e.length;i<r;++i){e[i]&&e[i].render(t)}},_renderBackgroundOrOverlay:function(t,e){var i=this[e+"Color"];if(i){t.fillStyle=i.toLive?i.toLive(t):i;t.fillRect(i.offsetX||0,i.offsetY||0,this.width,this.height)}i=this[e+"Image"];if(i){i.render(t)}},_renderBackground:function(t){this._renderBackgroundOrOverlay(t,"background")},_renderOverlay:function(t){this._renderBackgroundOrOverlay(t,"overlay")},renderTop:function(){var t=this.contextTop||this.contextContainer;this.clearContext(t);if(this.selection&&this._groupSelector){this._drawSelection()}this.fire("after:render");return this},getCenter:function(){return{top:this.getHeight()/2,left:this.getWidth()/2}},centerObjectH:function(t){this._centerObject(t,new fabric.Point(this.getCenter().left,t.getCenterPoint().y));this.renderAll();return this},centerObjectV:function(t){this._centerObject(t,new fabric.Point(t.getCenterPoint().x,this.getCenter().top));this.renderAll();return this},centerObject:function(t){var e=this.getCenter();this._centerObject(t,new fabric.Point(e.left,e.top));this.renderAll();return this},_centerObject:function(t,e){t.setPositionByOrigin(e,"center","center");return this},toDatalessJSON:function(t){return this.toDatalessObject(t)},toObject:function(t){return this._toObjectMethod("toObject",t)},toDatalessObject:function(t){return this._toObjectMethod("toDatalessObject",t)},_toObjectMethod:function(e,i){var r={objects:this._toObjects(e,i)};t(r,this.__serializeBgOverlay());fabric.util.populateWithProperties(this,r,i);return r},_toObjects:function(t,e){return this.getObjects().map(function(i){return this._toObject(i,t,e)},this)},_toObject:function(t,e,i){var r;if(!this.includeDefaultValues){r=t.includeDefaultValues;t.includeDefaultValues=false}var s=this._realizeGroupTransformOnObject(t),n=t[e](i);if(!this.includeDefaultValues){t.includeDefaultValues=r}this._unwindGroupTransformOnObject(t,s);return n},_realizeGroupTransformOnObject:function(t){var e=["angle","flipX","flipY","height","left","scaleX","scaleY","top","width"];if(t.group&&t.group===this.getActiveGroup()){var i={};e.forEach(function(e){i[e]=t[e]});this.getActiveGroup().realizeTransform(t);return i}else{return null}},_unwindGroupTransformOnObject:function(t,e){if(e){t.set(e)}},__serializeBgOverlay:function(){var t={background:this.backgroundColor&&this.backgroundColor.toObject?this.backgroundColor.toObject():this.backgroundColor};if(this.overlayColor){t.overlay=this.overlayColor.toObject?this.overlayColor.toObject():this.overlayColor}if(this.backgroundImage){t.backgroundImage=this.backgroundImage.toObject()}if(this.overlayImage){t.overlayImage=this.overlayImage.toObject()}return t},svgViewportTransformation:true,toSVG:function(t,e){t||(t={});var i=[];this._setSVGPreamble(i,t);this._setSVGHeader(i,t);this._setSVGBgOverlayColor(i,"backgroundColor");this._setSVGBgOverlayImage(i,"backgroundImage");this._setSVGObjects(i,e);this._setSVGBgOverlayColor(i,"overlayColor");this._setSVGBgOverlayImage(i,"overlayImage");i.push("</svg>");return i.join("")},_setSVGPreamble:function(t,e){if(e.suppressPreamble){return}t.push('<?xml version="1.0" encoding="',e.encoding||"UTF-8",'" standalone="no" ?>\n','<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" ','"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">\n')},_setSVGHeader:function(t,e){var i=e.width||this.width,s=e.height||this.height,n,o='viewBox="0 0 '+this.width+" "+this.height+'" ',a=fabric.Object.NUM_FRACTION_DIGITS;if(e.viewBox){o='viewBox="'+e.viewBox.x+" "+e.viewBox.y+" "+e.viewBox.width+" "+e.viewBox.height+'" '}else{if(this.svgViewportTransformation){n=this.viewportTransform;o='viewBox="'+r(-n[4]/n[0],a)+" "+r(-n[5]/n[3],a)+" "+r(this.width/n[0],a)+" "+r(this.height/n[3],a)+'" '}}t.push("<svg ",'xmlns="http://www.w3.org/2000/svg" ','xmlns:xlink="http://www.w3.org/1999/xlink" ','version="1.1" ','width="',i,'" ','height="',s,'" ',this.backgroundColor&&!this.backgroundColor.toLive?'style="background-color: '+this.backgroundColor+'" ':null,o,'xml:space="preserve">\n',"<desc>Created with Fabric.js ",fabric.version,"</desc>\n","<defs>",fabric.createSVGFontFacesMarkup(this.getObjects()),fabric.createSVGRefElementsMarkup(this),"</defs>\n")},_setSVGObjects:function(t,e){for(var i=0,r=this.getObjects(),s=r.length;i<s;i++){var n=r[i],o=this._realizeGroupTransformOnObject(n);t.push(n.toSVG(e));this._unwindGroupTransformOnObject(n,o)}},_setSVGBgOverlayImage:function(t,e){if(this[e]&&this[e].toSVG){t.push(this[e].toSVG())}},_setSVGBgOverlayColor:function(t,e){if(this[e]&&this[e].source){t.push('<rect x="',this[e].offsetX,'" y="',this[e].offsetY,'" ','width="',this[e].repeat==="repeat-y"||this[e].repeat==="no-repeat"?this[e].source.width:this.width,'" height="',this[e].repeat==="repeat-x"||this[e].repeat==="no-repeat"?this[e].source.height:this.height,'" fill="url(#'+e+'Pattern)"',"></rect>\n")}else if(this[e]&&e==="overlayColor"){t.push('<rect x="0" y="0" ','width="',this.width,'" height="',this.height,'" fill="',this[e],'"',"></rect>\n")}},sendToBack:function(t){if(!t){return this}var e=this.getActiveGroup?this.getActiveGroup():null,r,s,n;if(t===e){n=e._objects;for(r=n.length;r--;){s=n[r];i(this._objects,s);this._objects.unshift(s)}}else{i(this._objects,t);this._objects.unshift(t)}return this.renderAll&&this.renderAll()},bringToFront:function(t){if(!t){return this}var e=this.getActiveGroup?this.getActiveGroup():null,r,s,n;if(t===e){n=e._objects;for(r=0;r<n.length;r++){s=n[r];i(this._objects,s);this._objects.push(s)}}else{i(this._objects,t);this._objects.push(t)}return this.renderAll&&this.renderAll()},sendBackwards:function(t,e){if(!t){return this}var r=this.getActiveGroup?this.getActiveGroup():null,s,n,o,a,h;if(t===r){h=r._objects;for(s=0;s<h.length;s++){n=h[s];o=this._objects.indexOf(n);if(o!==0){a=o-1;i(this._objects,n);this._objects.splice(a,0,n)}}}else{o=this._objects.indexOf(t);if(o!==0){a=this._findNewLowerIndex(t,o,e);i(this._objects,t);this._objects.splice(a,0,t)}}this.renderAll&&this.renderAll();return this},_findNewLowerIndex:function(t,e,i){var r;if(i){r=e;for(var s=e-1;s>=0;--s){var n=t.intersectsWithObject(this._objects[s])||t.isContainedWithinObject(this._objects[s])||this._objects[s].isContainedWithinObject(t);if(n){r=s;break}}}else{r=e-1}return r},bringForward:function(t,e){if(!t){return this}var r=this.getActiveGroup?this.getActiveGroup():null,s,n,o,a,h;if(t===r){h=r._objects;for(s=h.length;s--;){n=h[s];o=this._objects.indexOf(n);if(o!==this._objects.length-1){a=o+1;i(this._objects,n);this._objects.splice(a,0,n)}}}else{o=this._objects.indexOf(t);if(o!==this._objects.length-1){a=this._findNewUpperIndex(t,o,e);i(this._objects,t);this._objects.splice(a,0,t)}}this.renderAll&&this.renderAll();return this},_findNewUpperIndex:function(t,e,i){var r;if(i){r=e;for(var s=e+1;s<this._objects.length;++s){var n=t.intersectsWithObject(this._objects[s])||t.isContainedWithinObject(this._objects[s])||this._objects[s].isContainedWithinObject(t);if(n){r=s;break}}}else{r=e+1}return r},moveTo:function(t,e){i(this._objects,t);this._objects.splice(e,0,t);return this.renderAll&&this.renderAll()},dispose:function(){this.clear();return this},toString:function(){return"#<fabric.Canvas ("+this.complexity()+"): "+"{ objects: "+this.getObjects().length+" }>"}});t(fabric.StaticCanvas.prototype,fabric.Observable);t(fabric.StaticCanvas.prototype,fabric.Collection);t(fabric.StaticCanvas.prototype,fabric.DataURLExporter);t(fabric.StaticCanvas,{EMPTY_JSON:'{"objects": [], "background": "white"}',supports:function(t){var e=fabric.util.createCanvasElement();if(!e||!e.getContext){return null}var i=e.getContext("2d");if(!i){return null}switch(t){case"getImageData":return typeof i.getImageData!=="undefined";case"setLineDash":return typeof i.setLineDash!=="undefined";case"toDataURL":return typeof e.toDataURL!=="undefined";case"toDataURLWithQuality":try{e.toDataURL("image/jpeg",0);return true}catch(r){}return false;default:return null}}});fabric.StaticCanvas.prototype.toJSON=fabric.StaticCanvas.prototype.toObject})();fabric.BaseBrush=fabric.util.createClass({color:"rgb(0, 0, 0)",width:1,shadow:null,strokeLineCap:"round",strokeLineJoin:"round",strokeDashArray:null,setShadow:function(t){this.shadow=new fabric.Shadow(t);return this},_setBrushStyles:function(){var t=this.canvas.contextTop;t.strokeStyle=this.color;t.lineWidth=this.width;t.lineCap=this.strokeLineCap;t.lineJoin=this.strokeLineJoin;if(this.strokeDashArray&&fabric.StaticCanvas.supports("setLineDash")){t.setLineDash(this.strokeDashArray)}},_setShadow:function(){if(!this.shadow){return}var t=this.canvas.contextTop;t.shadowColor=this.shadow.color;t.shadowBlur=this.shadow.blur;t.shadowOffsetX=this.shadow.offsetX;t.shadowOffsetY=this.shadow.offsetY},_resetShadow:function(){var t=this.canvas.contextTop;t.shadowColor="";t.shadowBlur=t.shadowOffsetX=t.shadowOffsetY=0}});(function(){fabric.PencilBrush=fabric.util.createClass(fabric.BaseBrush,{initialize:function(t){this.canvas=t;this._points=[]},onMouseDown:function(t){this._prepareForDrawing(t);this._captureDrawingPath(t);this._render()},onMouseMove:function(t){this._captureDrawingPath(t);this.canvas.clearContext(this.canvas.contextTop);this._render()},onMouseUp:function(){this._finalizeAndAddPath()},_prepareForDrawing:function(t){var e=new fabric.Point(t.x,t.y);this._reset();this._addPoint(e);this.canvas.contextTop.moveTo(e.x,e.y)},_addPoint:function(t){this._points.push(t)},_reset:function(){this._points.length=0;this._setBrushStyles();this._setShadow()},_captureDrawingPath:function(t){var e=new fabric.Point(t.x,t.y);this._addPoint(e)},_render:function(){var t=this.canvas.contextTop,e=this.canvas.viewportTransform,i=this._points[0],r=this._points[1];t.save();t.transform(e[0],e[1],e[2],e[3],e[4],e[5]);t.beginPath();if(this._points.length===2&&i.x===r.x&&i.y===r.y){i.x-=.5;r.x+=.5}t.moveTo(i.x,i.y);for(var s=1,n=this._points.length;s<n;s++){var o=i.midPointFrom(r);t.quadraticCurveTo(i.x,i.y,o.x,o.y);i=this._points[s];r=this._points[s+1]}t.lineTo(i.x,i.y);t.stroke();t.restore()},convertPointsToSVGPath:function(t){var e=[],i=new fabric.Point(t[0].x,t[0].y),r=new fabric.Point(t[1].x,t[1].y);e.push("M ",t[0].x," ",t[0].y," ");for(var s=1,n=t.length;s<n;s++){var o=i.midPointFrom(r);e.push("Q ",i.x," ",i.y," ",o.x," ",o.y," ");i=new fabric.Point(t[s].x,t[s].y);if(s+1<t.length){r=new fabric.Point(t[s+1].x,t[s+1].y)}}e.push("L ",i.x," ",i.y," ");return e},createPath:function(t){var e=new fabric.Path(t,{fill:null,stroke:this.color,strokeWidth:this.width,strokeLineCap:this.strokeLineCap,strokeLineJoin:this.strokeLineJoin,strokeDashArray:this.strokeDashArray,originX:"center",originY:"center"});if(this.shadow){this.shadow.affectStroke=true;e.setShadow(this.shadow)}return e},_finalizeAndAddPath:function(){var t=this.canvas.contextTop;t.closePath();var e=this.convertPointsToSVGPath(this._points).join("");if(e==="M 0 0 Q 0 0 0 0 L 0 0"){this.canvas.renderAll();return}var i=this.createPath(e);this.canvas.add(i);i.setCoords();this.canvas.clearContext(this.canvas.contextTop);this._resetShadow();this.canvas.renderAll();this.canvas.fire("path:created",{path:i})}})})();fabric.CircleBrush=fabric.util.createClass(fabric.BaseBrush,{width:10,initialize:function(t){this.canvas=t;this.points=[]},drawDot:function(t){var e=this.addPoint(t),i=this.canvas.contextTop,r=this.canvas.viewportTransform;i.save();i.transform(r[0],r[1],r[2],r[3],r[4],r[5]);i.fillStyle=e.fill;i.beginPath();i.arc(e.x,e.y,e.radius,0,Math.PI*2,false);i.closePath();i.fill();i.restore()},onMouseDown:function(t){this.points.length=0;this.canvas.clearContext(this.canvas.contextTop);this._setShadow();this.drawDot(t)},onMouseMove:function(t){this.drawDot(t)},onMouseUp:function(){var t=this.canvas.renderOnAddRemove;this.canvas.renderOnAddRemove=false;var e=[];for(var i=0,r=this.points.length;i<r;i++){var s=this.points[i],n=new fabric.Circle({radius:s.radius,left:s.x,top:s.y,originX:"center",originY:"center",fill:s.fill});this.shadow&&n.setShadow(this.shadow);e.push(n)}var o=new fabric.Group(e,{originX:"center",originY:"center"});o.canvas=this.canvas;this.canvas.add(o);this.canvas.fire("path:created",{path:o});this.canvas.clearContext(this.canvas.contextTop);this._resetShadow();this.canvas.renderOnAddRemove=t;this.canvas.renderAll()},addPoint:function(t){var e=new fabric.Point(t.x,t.y),i=fabric.util.getRandomInt(Math.max(0,this.width-20),this.width+20)/2,r=new fabric.Color(this.color).setAlpha(fabric.util.getRandomInt(0,100)/100).toRgba();e.radius=i;e.fill=r;this.points.push(e);return e}});fabric.SprayBrush=fabric.util.createClass(fabric.BaseBrush,{width:10,density:20,dotWidth:1,dotWidthVariance:1,randomOpacity:false,optimizeOverlapping:true,initialize:function(t){this.canvas=t;this.sprayChunks=[]},onMouseDown:function(t){this.sprayChunks.length=0;this.canvas.clearContext(this.canvas.contextTop);this._setShadow();this.addSprayChunk(t);this.render()},onMouseMove:function(t){this.addSprayChunk(t);this.render()},onMouseUp:function(){var t=this.canvas.renderOnAddRemove;this.canvas.renderOnAddRemove=false;var e=[];for(var i=0,r=this.sprayChunks.length;i<r;i++){var s=this.sprayChunks[i];for(var n=0,o=s.length;n<o;n++){var a=new fabric.Rect({width:s[n].width,height:s[n].width,left:s[n].x+1,top:s[n].y+1,originX:"center",originY:"center",fill:this.color});this.shadow&&a.setShadow(this.shadow);e.push(a)}}if(this.optimizeOverlapping){e=this._getOptimizedRects(e)}var h=new fabric.Group(e,{originX:"center",originY:"center"});h.canvas=this.canvas;this.canvas.add(h);this.canvas.fire("path:created",{path:h});this.canvas.clearContext(this.canvas.contextTop);this._resetShadow();this.canvas.renderOnAddRemove=t;this.canvas.renderAll()},_getOptimizedRects:function(t){var e={},i;for(var r=0,s=t.length;r<s;r++){i=t[r].left+""+t[r].top;if(!e[i]){e[i]=t[r]}}var n=[];for(i in e){n.push(e[i])}return n},render:function(){var t=this.canvas.contextTop;t.fillStyle=this.color;var e=this.canvas.viewportTransform;t.save();t.transform(e[0],e[1],e[2],e[3],e[4],e[5]);for(var i=0,r=this.sprayChunkPoints.length;i<r;i++){var s=this.sprayChunkPoints[i];if(typeof s.opacity!=="undefined"){t.globalAlpha=s.opacity}t.fillRect(s.x,s.y,s.width,s.width)}t.restore()},addSprayChunk:function(t){this.sprayChunkPoints=[];var e,i,r,s=this.width/2;for(var n=0;n<this.density;n++){e=fabric.util.getRandomInt(t.x-s,t.x+s);i=fabric.util.getRandomInt(t.y-s,t.y+s);if(this.dotWidthVariance){r=fabric.util.getRandomInt(Math.max(1,this.dotWidth-this.dotWidthVariance),this.dotWidth+this.dotWidthVariance)}else{r=this.dotWidth}var o=new fabric.Point(e,i);o.width=r;if(this.randomOpacity){o.opacity=fabric.util.getRandomInt(0,100)/100}this.sprayChunkPoints.push(o)}this.sprayChunks.push(this.sprayChunkPoints)}});fabric.PatternBrush=fabric.util.createClass(fabric.PencilBrush,{getPatternSrc:function(){var t=20,e=5,i=fabric.document.createElement("canvas"),r=i.getContext("2d");i.width=i.height=t+e;r.fillStyle=this.color;r.beginPath();r.arc(t/2,t/2,t/2,0,Math.PI*2,false);r.closePath();r.fill();return i},getPatternSrcFunction:function(){return String(this.getPatternSrc).replace("this.color",'"'+this.color+'"')},getPattern:function(){return this.canvas.contextTop.createPattern(this.source||this.getPatternSrc(),"repeat")},_setBrushStyles:function(){this.callSuper("_setBrushStyles");this.canvas.contextTop.strokeStyle=this.getPattern()},createPath:function(t){var e=this.callSuper("createPath",t);e.stroke=new fabric.Pattern({source:this.source||this.getPatternSrcFunction()});return e}});(function(){var t=fabric.util.getPointer,e=fabric.util.degreesToRadians,i=fabric.util.radiansToDegrees,r=Math.atan2,s=Math.abs,n=.5;fabric.Canvas=fabric.util.createClass(fabric.StaticCanvas,{initialize:function(t,e){e||(e={});this._initStatic(t,e);this._initInteractive();this._createCacheCanvas()},uniScaleTransform:false,uniScaleKey:"shiftKey",centeredScaling:false,centeredRotation:false,centeredKey:"altKey",altActionKey:"shiftKey",interactive:true,selection:true,selectionKey:"shiftKey",selectionColor:"rgba(100, 100, 255, 0.3)",selectionDashArray:[],selectionBorderColor:"rgba(255, 255, 255, 0.3)",selectionLineWidth:1,hoverCursor:"move",moveCursor:"move",defaultCursor:"default",freeDrawingCursor:"crosshair",rotationCursor:"crosshair",containerClass:"canvas-container",perPixelTargetFind:false,targetFindTolerance:0,skipTargetFind:false,isDrawingMode:false,_initInteractive:function(){this._currentTransform=null;this._groupSelector=null;this._initWrapperElement();this._createUpperCanvas();this._initEventListeners();this._initRetinaScaling();this.freeDrawingBrush=fabric.PencilBrush&&new fabric.PencilBrush(this);this.calcOffset()},_resetCurrentTransform:function(){var t=this._currentTransform;t.target.set({scaleX:t.original.scaleX,scaleY:t.original.scaleY,skewX:t.original.skewX,skewY:t.original.skewY,left:t.original.left,top:t.original.top});if(this._shouldCenterTransform(t.target)){if(t.action==="rotate"){this._setOriginToCenter(t.target)}else{if(t.originX!=="center"){if(t.originX==="right"){t.mouseXSign=-1}else{t.mouseXSign=1}}if(t.originY!=="center"){if(t.originY==="bottom"){t.mouseYSign=-1}else{t.mouseYSign=1}}t.originX="center";t.originY="center"}}else{t.originX=t.original.originX;t.originY=t.original.originY}},containsPoint:function(t,e){var i=this.getPointer(t,true),r=this._normalizePointer(e,i);return e.containsPoint(r)||e._findTargetCorner(i)},_normalizePointer:function(t,e){var i=this.getActiveGroup(),r=i&&t.type!=="group"&&i.contains(t),s,n;if(r){n=fabric.util.multiplyTransformMatrices(this.viewportTransform,i.calcTransformMatrix());n=fabric.util.invertTransform(n);e=fabric.util.transformPoint(e,n,false);s=fabric.util.transformPoint(i.getCenterPoint(),n,false);e.x-=s.x;e.y-=s.y}return{x:e.x,y:e.y}},isTargetTransparent:function(t,e,i){var r=t.hasBorders,s=t.transparentCorners,n=this.contextCache,o=t.group&&t.group===this.getActiveGroup();t.hasBorders=t.transparentCorners=false;if(o){n.save();n.transform.apply(n,t.group.calcTransformMatrix())}t.render(n);t.active&&t._renderControls(n);t.hasBorders=r;t.transparentCorners=s;var a=fabric.util.isTransparent(n,e,i,this.targetFindTolerance);o&&n.restore();this.clearContext(n);return a},_shouldClearSelection:function(t,e){var i=this.getActiveGroup(),r=this.getActiveObject();return!e||e&&i&&!i.contains(e)&&i!==e&&!t[this.selectionKey]||e&&!e.evented||e&&!e.selectable&&r&&r!==e},_shouldCenterTransform:function(t){if(!t){return}var e=this._currentTransform,i;if(e.action==="scale"||e.action==="scaleX"||e.action==="scaleY"){i=this.centeredScaling||t.centeredScaling}else if(e.action==="rotate"){i=this.centeredRotation||t.centeredRotation}return i?!e.altKey:e.altKey},_getOriginFromCorner:function(t,e){var i={x:t.originX,y:t.originY};if(e==="ml"||e==="tl"||e==="bl"){i.x="right"}else if(e==="mr"||e==="tr"||e==="br"){i.x="left"}if(e==="tl"||e==="mt"||e==="tr"){i.y="bottom"}else if(e==="bl"||e==="mb"||e==="br"){i.y="top"}return i},_getActionFromCorner:function(t,e,i){if(!e){return"drag"}switch(e){case"mtr":return"rotate";case"ml":case"mr":return i[this.altActionKey]?"skewY":"scaleX";case"mt":case"mb":return i[this.altActionKey]?"skewX":"scaleY";default:return"scale"}},_setupCurrentTransform:function(t,i){if(!i){return}var r=this.getPointer(t),s=i._findTargetCorner(this.getPointer(t,true)),n=this._getActionFromCorner(i,s,t),o=this._getOriginFromCorner(i,s);this._currentTransform={target:i,action:n,corner:s,scaleX:i.scaleX,scaleY:i.scaleY,skewX:i.skewX,skewY:i.skewY,offsetX:r.x-i.left,offsetY:r.y-i.top,originX:o.x,originY:o.y,ex:r.x,ey:r.y,lastX:r.x,lastY:r.y,left:i.left,top:i.top,theta:e(i.angle),width:i.width*i.scaleX,mouseXSign:1,mouseYSign:1,shiftKey:t.shiftKey,altKey:t[this.centeredKey]};this._currentTransform.original={left:i.left,top:i.top,scaleX:i.scaleX,scaleY:i.scaleY,skewX:i.skewX,skewY:i.skewY,originX:o.x,originY:o.y};this._resetCurrentTransform()},_translateObject:function(t,e){var i=this._currentTransform,r=i.target,s=t-i.offsetX,n=e-i.offsetY,o=!r.get("lockMovementX")&&r.left!==s,a=!r.get("lockMovementY")&&r.top!==n;o&&r.set("left",s);a&&r.set("top",n);return o||a},_changeSkewTransformOrigin:function(t,e,i){var r="originX",s={0:"center"},n=e.target.skewX,o="left",a="right",h=e.corner==="mt"||e.corner==="ml"?1:-1,c=1;t=t>0?1:-1;if(i==="y"){n=e.target.skewY;o="top";a="bottom";r="originY"}s[-1]=o;s[1]=a;e.target.flipX&&(c*=-1);e.target.flipY&&(c*=-1);if(n===0){e.skewSign=-h*t*c;e[r]=s[-t]}else{n=n>0?1:-1;e.skewSign=n;e[r]=s[n*h*c]}},_skewObject:function(t,e,i){var r=this._currentTransform,s=r.target,n=false,o=s.get("lockSkewingX"),a=s.get("lockSkewingY");if(o&&i==="x"||a&&i==="y"){return false}var h=s.getCenterPoint(),c=s.toLocalPoint(new fabric.Point(t,e),"center","center")[i],l=s.toLocalPoint(new fabric.Point(r.lastX,r.lastY),"center","center")[i],f,u,d=s._getTransformedDimensions();this._changeSkewTransformOrigin(c-l,r,i);f=s.toLocalPoint(new fabric.Point(t,e),r.originX,r.originY)[i],u=s.translateToOriginPoint(h,r.originX,r.originY);n=this._setObjectSkew(f,r,i,d);r.lastX=t;r.lastY=e;s.setPositionByOrigin(u,r.originX,r.originY);return n},_setObjectSkew:function(t,e,i,r){var s=e.target,n,o=false,a=e.skewSign,h,c,l,f,u,d,g,p;if(i==="x"){l="y";f="Y";u="X";g=0;p=s.skewY}else{l="x";f="X";u="Y";g=s.skewX;p=0}c=s._getTransformedDimensions(g,p);d=2*Math.abs(t)-c[i];if(d<=2){n=0}else{n=a*Math.atan(d/s["scale"+u]/(c[l]/s["scale"+f]));n=fabric.util.radiansToDegrees(n)}o=s["skew"+u]!==n;s.set("skew"+u,n);if(s["skew"+f]!==0){h=s._getTransformedDimensions();n=r[l]/h[l]*s["scale"+f];s.set("scale"+f,n)}return o},_scaleObject:function(t,e,i){var r=this._currentTransform,s=r.target,n=s.get("lockScalingX"),o=s.get("lockScalingY"),a=s.get("lockScalingFlip");if(n&&o){return false}var h=s.translateToOriginPoint(s.getCenterPoint(),r.originX,r.originY),c=s.toLocalPoint(new fabric.Point(t,e),r.originX,r.originY),l=s._getTransformedDimensions(),f=false;this._setLocalMouse(c,r);f=this._setObjectScale(c,r,n,o,i,a,l);s.setPositionByOrigin(h,r.originX,r.originY);return f},_setObjectScale:function(t,e,i,r,s,n,o){var a=e.target,h=false,c=false,l=false,f,u,d,g;d=t.x*a.scaleX/o.x;g=t.y*a.scaleY/o.y;f=a.scaleX!==d;u=a.scaleY!==g;if(n&&d<=0&&d<a.scaleX){h=true}if(n&&g<=0&&g<a.scaleY){c=true}if(s==="equally"&&!i&&!r){h||c||(l=this._scaleObjectEqually(t,a,e,o))}else if(!s){h||i||a.set("scaleX",d)&&(l=l||f);c||r||a.set("scaleY",g)&&(l=l||u)}else if(s==="x"&&!a.get("lockUniScaling")){h||i||a.set("scaleX",d)&&(l=l||f)}else if(s==="y"&&!a.get("lockUniScaling")){c||r||a.set("scaleY",g)&&(l=l||u)}e.newScaleX=d;e.newScaleY=g;h||c||this._flipObject(e,s);return l},_scaleObjectEqually:function(t,e,i,r){var s=t.y+t.x,n=r.y*i.original.scaleY/e.scaleY+r.x*i.original.scaleX/e.scaleX,o;i.newScaleX=i.original.scaleX*s/n;i.newScaleY=i.original.scaleY*s/n;o=i.newScaleX!==e.scaleX||i.newScaleY!==e.scaleY;e.set("scaleX",i.newScaleX);e.set("scaleY",i.newScaleY);return o},_flipObject:function(t,e){if(t.newScaleX<0&&e!=="y"){if(t.originX==="left"){t.originX="right"}else if(t.originX==="right"){t.originX="left"}}if(t.newScaleY<0&&e!=="x"){if(t.originY==="top"){t.originY="bottom"}else if(t.originY==="bottom"){t.originY="top"}}},_setLocalMouse:function(t,e){var i=e.target;if(e.originX==="right"){t.x*=-1}else if(e.originX==="center"){t.x*=e.mouseXSign*2;if(t.x<0){e.mouseXSign=-e.mouseXSign}}if(e.originY==="bottom"){t.y*=-1}else if(e.originY==="center"){t.y*=e.mouseYSign*2;if(t.y<0){e.mouseYSign=-e.mouseYSign}}if(s(t.x)>i.padding){if(t.x<0){t.x+=i.padding}else{t.x-=i.padding}}else{t.x=0}if(s(t.y)>i.padding){if(t.y<0){t.y+=i.padding}else{t.y-=i.padding}}else{t.y=0}},_rotateObject:function(t,e){var s=this._currentTransform;if(s.target.get("lockRotation")){return false}var n=r(s.ey-s.top,s.ex-s.left),o=r(e-s.top,t-s.left),a=i(o-n+s.theta);if(a<0){a=360+a}s.target.angle=a%360;return true},setCursor:function(t){this.upperCanvasEl.style.cursor=t},_resetObjectTransform:function(t){t.scaleX=1;t.scaleY=1;t.skewX=0;t.skewY=0;t.setAngle(0)},_drawSelection:function(){var t=this.contextTop,e=this._groupSelector,i=e.left,r=e.top,o=s(i),a=s(r);t.fillStyle=this.selectionColor;t.fillRect(e.ex-(i>0?0:-i),e.ey-(r>0?0:-r),o,a);t.lineWidth=this.selectionLineWidth;t.strokeStyle=this.selectionBorderColor;if(this.selectionDashArray.length>1){var h=e.ex+n-(i>0?0:o),c=e.ey+n-(r>0?0:a);t.beginPath();fabric.util.drawDashedLine(t,h,c,h+o,c,this.selectionDashArray);fabric.util.drawDashedLine(t,h,c+a-1,h+o,c+a-1,this.selectionDashArray);fabric.util.drawDashedLine(t,h,c,h,c+a,this.selectionDashArray);fabric.util.drawDashedLine(t,h+o-1,c,h+o-1,c+a,this.selectionDashArray);t.closePath();t.stroke()}else{t.strokeRect(e.ex+n-(i>0?0:o),e.ey+n-(r>0?0:a),o,a)}},_isLastRenderedObject:function(t){return this.controlsAboveOverlay&&this.lastRenderedObjectWithControlsAboveOverlay&&this.lastRenderedObjectWithControlsAboveOverlay.visible&&this.containsPoint(t,this.lastRenderedObjectWithControlsAboveOverlay)&&this.lastRenderedObjectWithControlsAboveOverlay._findTargetCorner(this.getPointer(t,true))},findTarget:function(t,e){if(this.skipTargetFind){return}if(this._isLastRenderedObject(t)){return this.lastRenderedObjectWithControlsAboveOverlay}var i=this.getActiveGroup();if(!e&&this._checkTarget(t,i,this.getPointer(t,true))){return i}var r=this._searchPossibleTargets(t,e);this._fireOverOutEvents(r,t);return r},_fireOverOutEvents:function(t,e){if(t){if(this._hoveredTarget!==t){if(this._hoveredTarget){this.fire("mouse:out",{target:this._hoveredTarget,e:e});this._hoveredTarget.fire("mouseout")}this.fire("mouse:over",{target:t,e:e});t.fire("mouseover");this._hoveredTarget=t}}else if(this._hoveredTarget){this.fire("mouse:out",{target:this._hoveredTarget,e:e});this._hoveredTarget.fire("mouseout");this._hoveredTarget=null}},_checkTarget:function(t,e,i){if(e&&e.visible&&e.evented&&this.containsPoint(t,e)){if((this.perPixelTargetFind||e.perPixelTargetFind)&&!e.isEditing){var r=this.isTargetTransparent(e,i.x,i.y);if(!r){return true}}else{return true}}},_searchPossibleTargets:function(t,e){var i,r=this.getPointer(t,true),s=this._objects.length;while(s--){if((!this._objects[s].group||e)&&this._checkTarget(t,this._objects[s],r)){this.relatedTarget=this._objects[s];i=this._objects[s];break}}return i},getPointer:function(e,i,r){if(!r){r=this.upperCanvasEl}var s=t(e),n=r.getBoundingClientRect(),o=n.width||0,a=n.height||0,h;if(!o||!a){if("top"in n&&"bottom"in n){a=Math.abs(n.top-n.bottom)}if("right"in n&&"left"in n){o=Math.abs(n.right-n.left)}}this.calcOffset();s.x=s.x-this._offset.left;s.y=s.y-this._offset.top;if(!i){s=fabric.util.transformPoint(s,fabric.util.invertTransform(this.viewportTransform))}if(o===0||a===0){h={width:1,height:1}}else{h={width:r.width/o,height:r.height/a}}return{x:s.x*h.width,y:s.y*h.height}},_createUpperCanvas:function(){var t=this.lowerCanvasEl.className.replace(/\s*lower-canvas\s*/,"");this.upperCanvasEl=this._createCanvasElement();fabric.util.addClass(this.upperCanvasEl,"upper-canvas "+t);this.wrapperEl.appendChild(this.upperCanvasEl);this._copyCanvasStyle(this.lowerCanvasEl,this.upperCanvasEl);this._applyCanvasStyle(this.upperCanvasEl);this.contextTop=this.upperCanvasEl.getContext("2d")},_createCacheCanvas:function(){this.cacheCanvasEl=this._createCanvasElement();this.cacheCanvasEl.setAttribute("width",this.width);this.cacheCanvasEl.setAttribute("height",this.height);this.contextCache=this.cacheCanvasEl.getContext("2d")},_initWrapperElement:function(){this.wrapperEl=fabric.util.wrapElement(this.lowerCanvasEl,"div",{"class":this.containerClass});fabric.util.setStyle(this.wrapperEl,{width:this.getWidth()+"px",height:this.getHeight()+"px",position:"relative"});fabric.util.makeElementUnselectable(this.wrapperEl)},_applyCanvasStyle:function(t){var e=this.getWidth()||t.width,i=this.getHeight()||t.height;fabric.util.setStyle(t,{position:"absolute",width:e+"px",height:i+"px",left:0,top:0});t.width=e;t.height=i;fabric.util.makeElementUnselectable(t)},_copyCanvasStyle:function(t,e){e.style.cssText=t.style.cssText},getSelectionContext:function(){return this.contextTop},getSelectionElement:function(){return this.upperCanvasEl},_setActiveObject:function(t){if(this._activeObject){this._activeObject.set("active",false)}this._activeObject=t;t.set("active",true)},setActiveObject:function(t,e){this._setActiveObject(t);this.renderAll();this.fire("object:selected",{target:t,e:e});t.fire("selected",{e:e});return this},getActiveObject:function(){return this._activeObject},_discardActiveObject:function(){if(this._activeObject){this._activeObject.set("active",false)}this._activeObject=null},discardActiveObject:function(t){this._discardActiveObject();this.renderAll();this.fire("selection:cleared",{e:t});return this},_setActiveGroup:function(t){this._activeGroup=t;if(t){t.set("active",true)}},setActiveGroup:function(t,e){this._setActiveGroup(t);if(t){this.fire("object:selected",{target:t,e:e});t.fire("selected",{e:e})}return this},getActiveGroup:function(){return this._activeGroup},_discardActiveGroup:function(){var t=this.getActiveGroup();if(t){t.destroy()}this.setActiveGroup(null)},discardActiveGroup:function(t){this._discardActiveGroup();this.fire("selection:cleared",{e:t});return this},deactivateAll:function(){var t=this.getObjects(),e=0,i=t.length;for(;e<i;e++){t[e].set("active",false)}this._discardActiveGroup();this._discardActiveObject();return this},deactivateAllWithDispatch:function(t){var e=this.getActiveGroup()||this.getActiveObject();if(e){this.fire("before:selection:cleared",{target:e,e:t})}this.deactivateAll();if(e){this.fire("selection:cleared",{e:t})}return this},dispose:function(){this.callSuper("dispose");var t=this.wrapperEl;this.removeListeners();t.removeChild(this.upperCanvasEl);t.removeChild(this.lowerCanvasEl);delete this.upperCanvasEl;if(t.parentNode){t.parentNode.replaceChild(this.lowerCanvasEl,this.wrapperEl)}delete this.wrapperEl;return this},drawControls:function(t){var e=this.getActiveGroup();if(e){e._renderControls(t)}else{this._drawObjectsControls(t)}},_drawObjectsControls:function(t){for(var e=0,i=this._objects.length;e<i;++e){if(!this._objects[e]||!this._objects[e].active){continue}this._objects[e]._renderControls(t);this.lastRenderedObjectWithControlsAboveOverlay=this._objects[e]}}});for(var o in fabric.StaticCanvas){if(o!=="prototype"){fabric.Canvas[o]=fabric.StaticCanvas[o]}}if(fabric.isTouchSupported){fabric.Canvas.prototype._setCursorFromEvent=function(){}}fabric.Element=fabric.Canvas})();(function(){var t={mt:0,tr:1,mr:2,br:3,mb:4,bl:5,ml:6,tl:7},e=fabric.util.addListener,i=fabric.util.removeListener;fabric.util.object.extend(fabric.Canvas.prototype,{cursorMap:["n-resize","ne-resize","e-resize","se-resize","s-resize","sw-resize","w-resize","nw-resize"],_initEventListeners:function(){this._bindEvents();e(fabric.window,"resize",this._onResize);e(this.upperCanvasEl,"mousedown",this._onMouseDown);e(this.upperCanvasEl,"mousemove",this._onMouseMove);e(this.upperCanvasEl,"mousewheel",this._onMouseWheel);e(this.upperCanvasEl,"mouseout",this._onMouseOut);e(this.upperCanvasEl,"touchstart",this._onMouseDown);e(this.upperCanvasEl,"touchmove",this._onMouseMove);if(typeof eventjs!=="undefined"&&"add"in eventjs){eventjs.add(this.upperCanvasEl,"gesture",this._onGesture);eventjs.add(this.upperCanvasEl,"drag",this._onDrag);eventjs.add(this.upperCanvasEl,"orientation",this._onOrientationChange);eventjs.add(this.upperCanvasEl,"shake",this._onShake);eventjs.add(this.upperCanvasEl,"longpress",this._onLongPress)}},_bindEvents:function(){this._onMouseDown=this._onMouseDown.bind(this);this._onMouseMove=this._onMouseMove.bind(this);this._onMouseUp=this._onMouseUp.bind(this);this._onResize=this._onResize.bind(this);
this._onGesture=this._onGesture.bind(this);this._onDrag=this._onDrag.bind(this);this._onShake=this._onShake.bind(this);this._onLongPress=this._onLongPress.bind(this);this._onOrientationChange=this._onOrientationChange.bind(this);this._onMouseWheel=this._onMouseWheel.bind(this);this._onMouseOut=this._onMouseOut.bind(this)},removeListeners:function(){i(fabric.window,"resize",this._onResize);i(this.upperCanvasEl,"mousedown",this._onMouseDown);i(this.upperCanvasEl,"mousemove",this._onMouseMove);i(this.upperCanvasEl,"mousewheel",this._onMouseWheel);i(this.upperCanvasEl,"mouseout",this._onMouseOut);i(this.upperCanvasEl,"touchstart",this._onMouseDown);i(this.upperCanvasEl,"touchmove",this._onMouseMove);if(typeof eventjs!=="undefined"&&"remove"in eventjs){eventjs.remove(this.upperCanvasEl,"gesture",this._onGesture);eventjs.remove(this.upperCanvasEl,"drag",this._onDrag);eventjs.remove(this.upperCanvasEl,"orientation",this._onOrientationChange);eventjs.remove(this.upperCanvasEl,"shake",this._onShake);eventjs.remove(this.upperCanvasEl,"longpress",this._onLongPress)}},_onGesture:function(t,e){this.__onTransformGesture&&this.__onTransformGesture(t,e)},_onDrag:function(t,e){this.__onDrag&&this.__onDrag(t,e)},_onMouseWheel:function(t,e){this.__onMouseWheel&&this.__onMouseWheel(t,e)},_onMouseOut:function(t){var e=this._hoveredTarget;this.fire("mouse:out",{target:e,e:t});this._hoveredTarget=null;e&&e.fire("mouseout",{e:t})},_onOrientationChange:function(t,e){this.__onOrientationChange&&this.__onOrientationChange(t,e)},_onShake:function(t,e){this.__onShake&&this.__onShake(t,e)},_onLongPress:function(t,e){this.__onLongPress&&this.__onLongPress(t,e)},_onMouseDown:function(t){this.__onMouseDown(t);e(fabric.document,"touchend",this._onMouseUp);e(fabric.document,"touchmove",this._onMouseMove);i(this.upperCanvasEl,"mousemove",this._onMouseMove);i(this.upperCanvasEl,"touchmove",this._onMouseMove);if(t.type==="touchstart"){i(this.upperCanvasEl,"mousedown",this._onMouseDown)}else{e(fabric.document,"mouseup",this._onMouseUp);e(fabric.document,"mousemove",this._onMouseMove)}},_onMouseUp:function(t){this.__onMouseUp(t);i(fabric.document,"mouseup",this._onMouseUp);i(fabric.document,"touchend",this._onMouseUp);i(fabric.document,"mousemove",this._onMouseMove);i(fabric.document,"touchmove",this._onMouseMove);e(this.upperCanvasEl,"mousemove",this._onMouseMove);e(this.upperCanvasEl,"touchmove",this._onMouseMove);if(t.type==="touchend"){var r=this;setTimeout(function(){e(r.upperCanvasEl,"mousedown",r._onMouseDown)},400)}},_onMouseMove:function(t){!this.allowTouchScrolling&&t.preventDefault&&t.preventDefault();this.__onMouseMove(t)},_onResize:function(){this.calcOffset()},_shouldRender:function(t,e){var i=this.getActiveGroup()||this.getActiveObject();return!!(t&&(t.isMoving||t!==i)||!t&&!!i||!t&&!i&&!this._groupSelector||e&&this._previousPointer&&this.selection&&(e.x!==this._previousPointer.x||e.y!==this._previousPointer.y))},__onMouseUp:function(t){var e,i=true,r=this._currentTransform;if(this.isDrawingMode&&this._isCurrentlyDrawing){this._onMouseUpInDrawingMode(t);return}if(r){this._finalizeCurrentTransform();i=!r.actionPerformed}e=i?this.findTarget(t,true):r.target;var s=this._shouldRender(e,this.getPointer(t));this._maybeGroupObjects(t);if(e){e.isMoving=false}s&&this.renderAll();this._handleCursorAndEvent(t,e)},_handleCursorAndEvent:function(t,e){this._setCursorFromEvent(t,e);this.fire("mouse:up",{target:e,e:t});e&&e.fire("mouseup",{e:t})},_finalizeCurrentTransform:function(){var t=this._currentTransform,e=t.target;if(e._scaling){e._scaling=false}e.setCoords();this._restoreOriginXY(e);if(t.actionPerformed||this.stateful&&e.hasStateChanged()){this.fire("object:modified",{target:e});e.fire("modified")}},_restoreOriginXY:function(t){if(this._previousOriginX&&this._previousOriginY){var e=t.translateToOriginPoint(t.getCenterPoint(),this._previousOriginX,this._previousOriginY);t.originX=this._previousOriginX;t.originY=this._previousOriginY;t.left=e.x;t.top=e.y;this._previousOriginX=null;this._previousOriginY=null}},_onMouseDownInDrawingMode:function(t){this._isCurrentlyDrawing=true;this.discardActiveObject(t).renderAll();if(this.clipTo){fabric.util.clipContext(this,this.contextTop)}var e=fabric.util.invertTransform(this.viewportTransform),i=fabric.util.transformPoint(this.getPointer(t,true),e);this.freeDrawingBrush.onMouseDown(i);this.fire("mouse:down",{e:t});var r=this.findTarget(t);if(typeof r!=="undefined"){r.fire("mousedown",{e:t,target:r})}},_onMouseMoveInDrawingMode:function(t){if(this._isCurrentlyDrawing){var e=fabric.util.invertTransform(this.viewportTransform),i=fabric.util.transformPoint(this.getPointer(t,true),e);this.freeDrawingBrush.onMouseMove(i)}this.setCursor(this.freeDrawingCursor);this.fire("mouse:move",{e:t});var r=this.findTarget(t);if(typeof r!=="undefined"){r.fire("mousemove",{e:t,target:r})}},_onMouseUpInDrawingMode:function(t){this._isCurrentlyDrawing=false;if(this.clipTo){this.contextTop.restore()}this.freeDrawingBrush.onMouseUp();this.fire("mouse:up",{e:t});var e=this.findTarget(t);if(typeof e!=="undefined"){e.fire("mouseup",{e:t,target:e})}},__onMouseDown:function(t){var e="which"in t?t.which===1:t.button===0;if(!e&&!fabric.isTouchSupported){return}if(this.isDrawingMode){this._onMouseDownInDrawingMode(t);return}if(this._currentTransform){return}var i=this.findTarget(t),r=this.getPointer(t,true);this._previousPointer=r;var s=this._shouldRender(i,r),n=this._shouldGroup(t,i);if(this._shouldClearSelection(t,i)){this._clearSelection(t,i,r)}else if(n){this._handleGrouping(t,i);i=this.getActiveGroup()}if(i){if(i.selectable&&(i.__corner||!n)){this._beforeTransform(t,i);this._setupCurrentTransform(t,i)}if(i!==this.getActiveGroup()&&i!==this.getActiveObject()){this.deactivateAll();i.selectable&&this.setActiveObject(i,t)}}s&&this.renderAll();this.fire("mouse:down",{target:i,e:t});i&&i.fire("mousedown",{e:t})},_beforeTransform:function(t,e){this.stateful&&e.saveState();if(e._findTargetCorner(this.getPointer(t))){this.onBeforeScaleRotate(e)}},_clearSelection:function(t,e,i){this.deactivateAllWithDispatch(t);if(e&&e.selectable){this.setActiveObject(e,t)}else if(this.selection){this._groupSelector={ex:i.x,ey:i.y,top:0,left:0}}},_setOriginToCenter:function(t){this._previousOriginX=this._currentTransform.target.originX;this._previousOriginY=this._currentTransform.target.originY;var e=t.getCenterPoint();t.originX="center";t.originY="center";t.left=e.x;t.top=e.y;this._currentTransform.left=t.left;this._currentTransform.top=t.top},_setCenterToOrigin:function(t){var e=t.translateToOriginPoint(t.getCenterPoint(),this._previousOriginX,this._previousOriginY);t.originX=this._previousOriginX;t.originY=this._previousOriginY;t.left=e.x;t.top=e.y;this._previousOriginX=null;this._previousOriginY=null},__onMouseMove:function(t){var e,i;if(this.isDrawingMode){this._onMouseMoveInDrawingMode(t);return}if(typeof t.touches!=="undefined"&&t.touches.length>1){return}var r=this._groupSelector;if(r){i=this.getPointer(t,true);r.left=i.x-r.ex;r.top=i.y-r.ey;this.renderTop()}else if(!this._currentTransform){e=this.findTarget(t);this._setCursorFromEvent(t,e)}else{this._transformObject(t)}this.fire("mouse:move",{target:e,e:t});e&&e.fire("mousemove",{e:t})},_transformObject:function(t){var e=this.getPointer(t),i=this._currentTransform;i.reset=false,i.target.isMoving=true;this._beforeScaleTransform(t,i);this._performTransformAction(t,i,e);this.renderAll()},_performTransformAction:function(t,e,i){var r=i.x,s=i.y,n=e.target,o=e.action,a=false;if(o==="rotate"){(a=this._rotateObject(r,s))&&this._fire("rotating",n,t)}else if(o==="scale"){(a=this._onScale(t,e,r,s))&&this._fire("scaling",n,t)}else if(o==="scaleX"){(a=this._scaleObject(r,s,"x"))&&this._fire("scaling",n,t)}else if(o==="scaleY"){(a=this._scaleObject(r,s,"y"))&&this._fire("scaling",n,t)}else if(o==="skewX"){(a=this._skewObject(r,s,"x"))&&this._fire("skewing",n,t)}else if(o==="skewY"){(a=this._skewObject(r,s,"y"))&&this._fire("skewing",n,t)}else{a=this._translateObject(r,s);if(a){this._fire("moving",n,t);this.setCursor(n.moveCursor||this.moveCursor)}}e.actionPerformed=a},_fire:function(t,e,i){this.fire("object:"+t,{target:e,e:i});e.fire(t,{e:i})},_beforeScaleTransform:function(t,e){if(e.action==="scale"||e.action==="scaleX"||e.action==="scaleY"){var i=this._shouldCenterTransform(e.target);if(i&&(e.originX!=="center"||e.originY!=="center")||!i&&e.originX==="center"&&e.originY==="center"){this._resetCurrentTransform();e.reset=true}}},_onScale:function(t,e,i,r){if((t[this.uniScaleKey]||this.uniScaleTransform)&&!e.target.get("lockUniScaling")){e.currentAction="scale";return this._scaleObject(i,r)}else{if(!e.reset&&e.currentAction==="scale"){this._resetCurrentTransform()}e.currentAction="scaleEqually";return this._scaleObject(i,r,"equally")}},_setCursorFromEvent:function(t,e){if(!e){this.setCursor(this.defaultCursor);return false}var i=e.hoverCursor||this.hoverCursor;if(!e.selectable){this.setCursor(i)}else{var r=this.getActiveGroup(),s=e._findTargetCorner&&(!r||!r.contains(e))&&e._findTargetCorner(this.getPointer(t,true));if(!s){this.setCursor(i)}else{this._setCornerCursor(s,e,t)}}return true},_setCornerCursor:function(e,i,r){if(e in t){this.setCursor(this._getRotatedCornerCursor(e,i,r))}else if(e==="mtr"&&i.hasRotatingPoint){this.setCursor(this.rotationCursor)}else{this.setCursor(this.defaultCursor);return false}},_getRotatedCornerCursor:function(e,i,r){var s=Math.round(i.getAngle()%360/45);if(s<0){s+=8}s+=t[e];if(r[this.altActionKey]&&t[e]%2===0){s+=2}s%=8;return this.cursorMap[s]}})})();(function(){var t=Math.min,e=Math.max;fabric.util.object.extend(fabric.Canvas.prototype,{_shouldGroup:function(t,e){var i=this.getActiveObject();return t[this.selectionKey]&&e&&e.selectable&&(this.getActiveGroup()||i&&i!==e)&&this.selection},_handleGrouping:function(t,e){if(e===this.getActiveGroup()){e=this.findTarget(t,true);if(!e||e.isType("group")){return}}if(this.getActiveGroup()){this._updateActiveGroup(e,t)}else{this._createActiveGroup(e,t)}if(this._activeGroup){this._activeGroup.saveCoords()}},_updateActiveGroup:function(t,e){var i=this.getActiveGroup();if(i.contains(t)){i.removeWithUpdate(t);t.set("active",false);if(i.size()===1){this.discardActiveGroup(e);this.setActiveObject(i.item(0));return}}else{i.addWithUpdate(t)}this.fire("selection:created",{target:i,e:e});i.set("active",true)},_createActiveGroup:function(t,e){if(this._activeObject&&t!==this._activeObject){var i=this._createGroup(t);i.addWithUpdate();this.setActiveGroup(i);this._activeObject=null;this.fire("selection:created",{target:i,e:e})}t.set("active",true)},_createGroup:function(t){var e=this.getObjects(),i=e.indexOf(this._activeObject)<e.indexOf(t),r=i?[this._activeObject,t]:[t,this._activeObject];return new fabric.Group(r,{canvas:this})},_groupSelectedObjects:function(t){var e=this._collectObjects();if(e.length===1){this.setActiveObject(e[0],t)}else if(e.length>1){e=new fabric.Group(e.reverse(),{canvas:this});e.addWithUpdate();this.setActiveGroup(e,t);e.saveCoords();this.fire("selection:created",{target:e});this.renderAll()}},_collectObjects:function(){var i=[],r,s=this._groupSelector.ex,n=this._groupSelector.ey,o=s+this._groupSelector.left,a=n+this._groupSelector.top,h=new fabric.Point(t(s,o),t(n,a)),c=new fabric.Point(e(s,o),e(n,a)),l=s===o&&n===a;for(var f=this._objects.length;f--;){r=this._objects[f];if(!r||!r.selectable||!r.visible){continue}if(r.intersectsWithRect(h,c)||r.isContainedWithinRect(h,c)||r.containsPoint(h)||r.containsPoint(c)){r.set("active",true);i.push(r);if(l){break}}}return i},_maybeGroupObjects:function(t){if(this.selection&&this._groupSelector){this._groupSelectedObjects(t)}var e=this.getActiveGroup();if(e){e.setObjectsCoords().setCoords();e.isMoving=false;this.setCursor(this.defaultCursor)}this._groupSelector=null;this._currentTransform=null}})})();fabric.util.object.extend(fabric.StaticCanvas.prototype,{toDataURL:function(t){t||(t={});var e=t.format||"png",i=t.quality||1,r=t.multiplier||1,s={left:t.left,top:t.top,width:t.width,height:t.height};if(this._isRetinaScaling()){r*=fabric.devicePixelRatio}if(r!==1){return this.__toDataURLWithMultiplier(e,i,s,r)}else{return this.__toDataURL(e,i,s)}},__toDataURL:function(t,e,i){this.renderAll();var r=this.contextContainer.canvas,s=this.__getCroppedCanvas(r,i);if(t==="jpg"){t="jpeg"}var n=fabric.StaticCanvas.supports("toDataURLWithQuality")?(s||r).toDataURL("image/"+t,e):(s||r).toDataURL("image/"+t);if(s){s=null}return n},__getCroppedCanvas:function(t,e){var i,r,s="left"in e||"top"in e||"width"in e||"height"in e;if(s){i=fabric.util.createCanvasElement();r=i.getContext("2d");i.width=e.width||this.width;i.height=e.height||this.height;r.drawImage(t,-e.left||0,-e.top||0)}return i},__toDataURLWithMultiplier:function(t,e,i,r){var s=this.getWidth(),n=this.getHeight(),o=s*r,a=n*r,h=this.getActiveObject(),c=this.getActiveGroup(),l=this.getZoom(),f=l*r/fabric.devicePixelRatio;if(r>1){this.setDimensions({width:o,height:a})}this.setZoom(f);if(i.left){i.left*=r}if(i.top){i.top*=r}if(i.width){i.width*=r}else if(r<1){i.width=o}if(i.height){i.height*=r}else if(r<1){i.height=a}if(c){this._tempRemoveBordersControlsFromGroup(c)}else if(h&&this.deactivateAll){this.deactivateAll()}var u=this.__toDataURL(t,e,i);if(c){this._restoreBordersControlsOnGroup(c)}else if(h&&this.setActiveObject){this.setActiveObject(h)}this.setZoom(l);this.setDimensions({width:s,height:n});return u},toDataURLWithMultiplier:function(t,e,i){return this.toDataURL({format:t,multiplier:e,quality:i})},_tempRemoveBordersControlsFromGroup:function(t){t.origHasControls=t.hasControls;t.origBorderColor=t.borderColor;t.hasControls=true;t.borderColor="rgba(0,0,0,0)";t.forEachObject(function(t){t.origBorderColor=t.borderColor;t.borderColor="rgba(0,0,0,0)"})},_restoreBordersControlsOnGroup:function(t){t.hideControls=t.origHideControls;t.borderColor=t.origBorderColor;t.forEachObject(function(t){t.borderColor=t.origBorderColor;delete t.origBorderColor})}});fabric.util.object.extend(fabric.StaticCanvas.prototype,{loadFromDatalessJSON:function(t,e,i){return this.loadFromJSON(t,e,i)},loadFromJSON:function(t,e,i){if(!t){return}var r=typeof t==="string"?JSON.parse(t):fabric.util.object.clone(t);this.clear();var s=this;this._enlivenObjects(r.objects,function(){s._setBgOverlay(r,e)},i);delete r.objects;delete r.backgroundImage;delete r.overlayImage;delete r.background;delete r.overlay;for(var n in r){this[n]=r[n]}return this},_setBgOverlay:function(t,e){var i=this,r={backgroundColor:false,overlayColor:false,backgroundImage:false,overlayImage:false};if(!t.backgroundImage&&!t.overlayImage&&!t.background&&!t.overlay){e&&e();return}var s=function(){if(r.backgroundImage&&r.overlayImage&&r.backgroundColor&&r.overlayColor){i.renderAll();e&&e()}};this.__setBgOverlay("backgroundImage",t.backgroundImage,r,s);this.__setBgOverlay("overlayImage",t.overlayImage,r,s);this.__setBgOverlay("backgroundColor",t.background,r,s);this.__setBgOverlay("overlayColor",t.overlay,r,s);s()},__setBgOverlay:function(t,e,i,r){var s=this;if(!e){i[t]=true;return}if(t==="backgroundImage"||t==="overlayImage"){fabric.Image.fromObject(e,function(e){s[t]=e;i[t]=true;r&&r()})}else{this["set"+fabric.util.string.capitalize(t,true)](e,function(){i[t]=true;r&&r()})}},_enlivenObjects:function(t,e,i){var r=this;if(!t||t.length===0){e&&e();return}var s=this.renderOnAddRemove;this.renderOnAddRemove=false;fabric.util.enlivenObjects(t,function(t){t.forEach(function(t,e){r.insertAt(t,e,true)});r.renderOnAddRemove=s;e&&e()},null,i)},_toDataURL:function(t,e){this.clone(function(i){e(i.toDataURL(t))})},_toDataURLWithMultiplier:function(t,e,i){this.clone(function(r){i(r.toDataURLWithMultiplier(t,e))})},clone:function(t,e){var i=JSON.stringify(this.toJSON(e));this.cloneWithoutData(function(e){e.loadFromJSON(i,function(){t&&t(e)})})},cloneWithoutData:function(t){var e=fabric.document.createElement("canvas");e.width=this.getWidth();e.height=this.getHeight();var i=new fabric.Canvas(e);i.clipTo=this.clipTo;if(this.backgroundImage){i.setBackgroundImage(this.backgroundImage.src,function(){i.renderAll();t&&t(i)});i.backgroundImageOpacity=this.backgroundImageOpacity;i.backgroundImageStretch=this.backgroundImageStretch}else{t&&t(i)}}});(function(t){"use strict";var e=t.fabric||(t.fabric={}),i=e.util.object.extend,r=e.util.toFixed,s=e.util.string.capitalize,n=e.util.degreesToRadians,o=e.StaticCanvas.supports("setLineDash");if(e.Object){return}e.Object=e.util.createClass({type:"object",originX:"left",originY:"top",top:0,left:0,width:0,height:0,scaleX:1,scaleY:1,flipX:false,flipY:false,opacity:1,angle:0,skewX:0,skewY:0,cornerSize:13,transparentCorners:true,hoverCursor:null,moveCursor:null,padding:0,borderColor:"rgba(102,153,255,0.75)",borderDashArray:null,cornerColor:"rgba(102,153,255,0.5)",cornerStrokeColor:null,cornerStyle:"rect",cornerDashArray:null,centeredScaling:false,centeredRotation:true,fill:"rgb(0,0,0)",fillRule:"nonzero",globalCompositeOperation:"source-over",backgroundColor:"",selectionBackgroundColor:"",stroke:null,strokeWidth:1,strokeDashArray:null,strokeLineCap:"butt",strokeLineJoin:"miter",strokeMiterLimit:10,shadow:null,borderOpacityWhenMoving:.4,borderScaleFactor:1,transformMatrix:null,minScaleLimit:.01,selectable:true,evented:true,visible:true,hasControls:true,hasBorders:true,hasRotatingPoint:true,rotatingPointOffset:40,perPixelTargetFind:false,includeDefaultValues:true,clipTo:null,lockMovementX:false,lockMovementY:false,lockRotation:false,lockScalingX:false,lockScalingY:false,lockUniScaling:false,lockSkewingX:false,lockSkewingY:false,lockScalingFlip:false,stateProperties:("top left width height scaleX scaleY flipX flipY originX originY transformMatrix "+"stroke strokeWidth strokeDashArray strokeLineCap strokeLineJoin strokeMiterLimit "+"angle opacity fill fillRule globalCompositeOperation shadow clipTo visible backgroundColor "+"alignX alignY meetOrSlice skewX skewY").split(" "),initialize:function(t){if(t){this.setOptions(t)}},_initGradient:function(t){if(t.fill&&t.fill.colorStops&&!(t.fill instanceof e.Gradient)){this.set("fill",new e.Gradient(t.fill))}if(t.stroke&&t.stroke.colorStops&&!(t.stroke instanceof e.Gradient)){this.set("stroke",new e.Gradient(t.stroke))}},_initPattern:function(t){if(t.fill&&t.fill.source&&!(t.fill instanceof e.Pattern)){this.set("fill",new e.Pattern(t.fill))}if(t.stroke&&t.stroke.source&&!(t.stroke instanceof e.Pattern)){this.set("stroke",new e.Pattern(t.stroke))}},_initClipping:function(t){if(!t.clipTo||typeof t.clipTo!=="string"){return}var i=e.util.getFunctionBody(t.clipTo);if(typeof i!=="undefined"){this.clipTo=new Function("ctx",i)}},setOptions:function(t){for(var e in t){this.set(e,t[e])}this._initGradient(t);this._initPattern(t);this._initClipping(t)},transform:function(t,e){if(this.group&&this.canvas.preserveObjectStacking&&this.group===this.canvas._activeGroup){this.group.transform(t)}var i=e?this._getLeftTopCoords():this.getCenterPoint();t.translate(i.x,i.y);t.rotate(n(this.angle));t.scale(this.scaleX*(this.flipX?-1:1),this.scaleY*(this.flipY?-1:1));t.transform(1,0,Math.tan(n(this.skewX)),1,0,0);t.transform(1,Math.tan(n(this.skewY)),0,1,0,0)},toObject:function(t){var i=e.Object.NUM_FRACTION_DIGITS,s={type:this.type,originX:this.originX,originY:this.originY,left:r(this.left,i),top:r(this.top,i),width:r(this.width,i),height:r(this.height,i),fill:this.fill&&this.fill.toObject?this.fill.toObject():this.fill,stroke:this.stroke&&this.stroke.toObject?this.stroke.toObject():this.stroke,strokeWidth:r(this.strokeWidth,i),strokeDashArray:this.strokeDashArray?this.strokeDashArray.concat():this.strokeDashArray,strokeLineCap:this.strokeLineCap,strokeLineJoin:this.strokeLineJoin,strokeMiterLimit:r(this.strokeMiterLimit,i),scaleX:r(this.scaleX,i),scaleY:r(this.scaleY,i),angle:r(this.getAngle(),i),flipX:this.flipX,flipY:this.flipY,opacity:r(this.opacity,i),shadow:this.shadow&&this.shadow.toObject?this.shadow.toObject():this.shadow,visible:this.visible,clipTo:this.clipTo&&String(this.clipTo),backgroundColor:this.backgroundColor,fillRule:this.fillRule,globalCompositeOperation:this.globalCompositeOperation,transformMatrix:this.transformMatrix?this.transformMatrix.concat():this.transformMatrix,skewX:r(this.skewX,i),skewY:r(this.skewY,i)};if(!this.includeDefaultValues){s=this._removeDefaultValues(s)}e.util.populateWithProperties(this,s,t);return s},toDatalessObject:function(t){return this.toObject(t)},_removeDefaultValues:function(t){var i=e.util.getKlass(t.type).prototype,r=i.stateProperties;r.forEach(function(e){if(t[e]===i[e]){delete t[e]}var r=Object.prototype.toString.call(t[e])==="[object Array]"&&Object.prototype.toString.call(i[e])==="[object Array]";if(r&&t[e].length===0&&i[e].length===0){delete t[e]}});return t},toString:function(){return"#<fabric."+s(this.type)+">"},get:function(t){return this[t]},_setObject:function(t){for(var e in t){this._set(e,t[e])}},set:function(t,e){if(typeof t==="object"){this._setObject(t)}else{if(typeof e==="function"&&t!=="clipTo"){this._set(t,e(this.get(t)))}else{this._set(t,e)}}return this},_set:function(t,i){var r=t==="scaleX"||t==="scaleY";if(r){i=this._constrainScale(i)}if(t==="scaleX"&&i<0){this.flipX=!this.flipX;i*=-1}else if(t==="scaleY"&&i<0){this.flipY=!this.flipY;i*=-1}else if(t==="shadow"&&i&&!(i instanceof e.Shadow)){i=new e.Shadow(i)}this[t]=i;if(t==="width"||t==="height"){this.minScaleLimit=Math.min(.1,1/Math.max(this.width,this.height))}return this},setOnGroup:function(){},toggle:function(t){var e=this.get(t);if(typeof e==="boolean"){this.set(t,!e)}return this},setSourcePath:function(t){this.sourcePath=t;return this},getViewportTransform:function(){if(this.canvas&&this.canvas.viewportTransform){return this.canvas.viewportTransform}return[1,0,0,1,0,0]},render:function(t,i){if(this.width===0&&this.height===0||!this.visible){return}t.save();this._setupCompositeOperation(t);this.drawSelectionBackground(t);if(!i){this.transform(t)}this._setStrokeStyles(t);this._setFillStyles(t);if(this.transformMatrix){t.transform.apply(t,this.transformMatrix)}this._setOpacity(t);this._setShadow(t);this.clipTo&&e.util.clipContext(this,t);this._render(t,i);this.clipTo&&t.restore();t.restore()},_setOpacity:function(t){if(this.group){this.group._setOpacity(t)}t.globalAlpha*=this.opacity},_setStrokeStyles:function(t){if(this.stroke){t.lineWidth=this.strokeWidth;t.lineCap=this.strokeLineCap;t.lineJoin=this.strokeLineJoin;t.miterLimit=this.strokeMiterLimit;t.strokeStyle=this.stroke.toLive?this.stroke.toLive(t,this):this.stroke}},_setFillStyles:function(t){if(this.fill){t.fillStyle=this.fill.toLive?this.fill.toLive(t,this):this.fill}},_setLineDash:function(t,e,i){if(!e){return}if(1&e.length){e.push.apply(e,e)}if(o){t.setLineDash(e)}else{i&&i(t)}},_renderControls:function(t,i){if(!this.active||i||this.group&&this.group!==this.canvas.getActiveGroup()){return}var r=this.getViewportTransform(),s=this.calcTransformMatrix(),o;s=e.util.multiplyTransformMatrices(r,s);o=e.util.qrDecompose(s);t.save();t.translate(o.translateX,o.translateY);t.lineWidth=1/this.borderScaleFactor;t.globalAlpha=this.isMoving?this.borderOpacityWhenMoving:1;if(this.group&&this.group===this.canvas.getActiveGroup()){t.rotate(n(o.angle));this.drawBordersInGroup(t,o)}else{t.rotate(n(this.angle));this.drawBorders(t)}this.drawControls(t);t.restore()},_setShadow:function(t){if(!this.shadow){return}var i=this.canvas&&this.canvas.viewportTransform[0]||1,r=this.canvas&&this.canvas.viewportTransform[3]||1;if(this.canvas&&this.canvas._isRetinaScaling()){i*=e.devicePixelRatio;r*=e.devicePixelRatio}t.shadowColor=this.shadow.color;t.shadowBlur=this.shadow.blur*(i+r)*(this.scaleX+this.scaleY)/4;t.shadowOffsetX=this.shadow.offsetX*i*this.scaleX;t.shadowOffsetY=this.shadow.offsetY*r*this.scaleY},_removeShadow:function(t){if(!this.shadow){return}t.shadowColor="";t.shadowBlur=t.shadowOffsetX=t.shadowOffsetY=0},_renderFill:function(t){if(!this.fill){return}t.save();if(this.fill.gradientTransform){var e=this.fill.gradientTransform;t.transform.apply(t,e)}if(this.fill.toLive){t.translate(-this.width/2+this.fill.offsetX||0,-this.height/2+this.fill.offsetY||0)}if(this.fillRule==="evenodd"){t.fill("evenodd")}else{t.fill()}t.restore()},_renderStroke:function(t){if(!this.stroke||this.strokeWidth===0){return}if(this.shadow&&!this.shadow.affectStroke){this._removeShadow(t)}t.save();this._setLineDash(t,this.strokeDashArray,this._renderDashedStroke);if(this.stroke.gradientTransform){var e=this.stroke.gradientTransform;t.transform.apply(t,e)}if(this.stroke.toLive){t.translate(-this.width/2+this.stroke.offsetX||0,-this.height/2+this.stroke.offsetY||0)}t.stroke();t.restore()},clone:function(t,i){if(this.constructor.fromObject){return this.constructor.fromObject(this.toObject(i),t)}return new e.Object(this.toObject(i))},cloneAsImage:function(t){var i=this.toDataURL();e.util.loadImage(i,function(i){if(t){t(new e.Image(i))}});return this},toDataURL:function(t){t||(t={});var i=e.util.createCanvasElement(),r=this.getBoundingRect();i.width=r.width;i.height=r.height;e.util.wrapElement(i,"div");var s=new e.StaticCanvas(i);if(t.format==="jpg"){t.format="jpeg"}if(t.format==="jpeg"){s.backgroundColor="#fff"}var n={active:this.get("active"),left:this.getLeft(),top:this.getTop()};this.set("active",false);this.setPositionByOrigin(new e.Point(s.getWidth()/2,s.getHeight()/2),"center","center");var o=this.canvas;s.add(this);var a=s.toDataURL(t);this.set(n).setCoords();this.canvas=o;s.dispose();s=null;return a},isType:function(t){return this.type===t},complexity:function(){return 0},toJSON:function(t){return this.toObject(t)},setGradient:function(t,i){i||(i={});var r={colorStops:[]};r.type=i.type||(i.r1||i.r2?"radial":"linear");r.coords={x1:i.x1,y1:i.y1,x2:i.x2,y2:i.y2};if(i.r1||i.r2){r.coords.r1=i.r1;r.coords.r2=i.r2}i.gradientTransform&&(r.gradientTransform=i.gradientTransform);for(var s in i.colorStops){var n=new e.Color(i.colorStops[s]);r.colorStops.push({offset:s,color:n.toRgb(),opacity:n.getAlpha()})}return this.set(t,e.Gradient.forObject(this,r))},setPatternFill:function(t){return this.set("fill",new e.Pattern(t))},setShadow:function(t){return this.set("shadow",t?new e.Shadow(t):null)},setColor:function(t){this.set("fill",t);return this},setAngle:function(t){var e=(this.originX!=="center"||this.originY!=="center")&&this.centeredRotation;if(e){this._setOriginToCenter()}this.set("angle",t);if(e){this._resetOrigin()}return this},centerH:function(){this.canvas.centerObjectH(this);return this},centerV:function(){this.canvas.centerObjectV(this);return this},center:function(){this.canvas.centerObject(this);return this},remove:function(){this.canvas.remove(this);return this},getLocalPointer:function(t,i){i=i||this.canvas.getPointer(t);var r=new e.Point(i.x,i.y),s=this._getLeftTopCoords();if(this.angle){r=e.util.rotatePoint(r,s,e.util.degreesToRadians(-this.angle))}return{x:r.x-s.x,y:r.y-s.y}},_setupCompositeOperation:function(t){if(this.globalCompositeOperation){t.globalCompositeOperation=this.globalCompositeOperation}}});e.util.createAccessors(e.Object);e.Object.prototype.rotate=e.Object.prototype.setAngle;i(e.Object.prototype,e.Observable);e.Object.NUM_FRACTION_DIGITS=2;e.Object.__uid=0})(typeof exports!=="undefined"?exports:this);(function(){var t=fabric.util.degreesToRadians,e={left:-.5,center:0,right:.5},i={top:-.5,center:0,bottom:.5};fabric.util.object.extend(fabric.Object.prototype,{translateToGivenOrigin:function(t,r,s,n,o){var a=t.x,h=t.y,c=e[n]-e[r],l=i[o]-i[s],f;if(c||l){f=this._getTransformedDimensions();a=t.x+c*f.x;h=t.y+l*f.y}return new fabric.Point(a,h)},translateToCenterPoint:function(e,i,r){var s=this.translateToGivenOrigin(e,i,r,"center","center");if(this.angle){return fabric.util.rotatePoint(s,e,t(this.angle))}return s},translateToOriginPoint:function(e,i,r){var s=this.translateToGivenOrigin(e,"center","center",i,r);if(this.angle){return fabric.util.rotatePoint(s,e,t(this.angle))}return s},getCenterPoint:function(){var t=new fabric.Point(this.left,this.top);return this.translateToCenterPoint(t,this.originX,this.originY)},getPointByOrigin:function(t,e){var i=this.getCenterPoint();return this.translateToOriginPoint(i,t,e)},toLocalPoint:function(e,i,r){var s=this.getCenterPoint(),n,o;if(i&&r){n=this.translateToGivenOrigin(s,"center","center",i,r)}else{n=new fabric.Point(this.left,this.top)}o=new fabric.Point(e.x,e.y);if(this.angle){o=fabric.util.rotatePoint(o,s,-t(this.angle))}return o.subtractEquals(n)},setPositionByOrigin:function(t,e,i){var r=this.translateToCenterPoint(t,e,i),s=this.translateToOriginPoint(r,this.originX,this.originY);this.set("left",s.x);this.set("top",s.y)},adjustPosition:function(i){var r=t(this.angle),s=this.getWidth(),n=Math.cos(r)*s,o=Math.sin(r)*s;this.left+=n*(e[i]-e[this.originX]);this.top+=o*(e[i]-e[this.originX]);this.setCoords();this.originX=i},_setOriginToCenter:function(){this._originalOriginX=this.originX;this._originalOriginY=this.originY;var t=this.getCenterPoint();this.originX="center";this.originY="center";this.left=t.x;this.top=t.y},_resetOrigin:function(){var t=this.translateToOriginPoint(this.getCenterPoint(),this._originalOriginX,this._originalOriginY);this.originX=this._originalOriginX;this.originY=this._originalOriginY;this.left=t.x;this.top=t.y;this._originalOriginX=null;this._originalOriginY=null},_getLeftTopCoords:function(){return this.translateToOriginPoint(this.getCenterPoint(),"left","top")}})})();(function(){function t(t){return[new fabric.Point(t.tl.x,t.tl.y),new fabric.Point(t.tr.x,t.tr.y),new fabric.Point(t.br.x,t.br.y),new fabric.Point(t.bl.x,t.bl.y)]}var e=fabric.util.degreesToRadians,i=fabric.util.multiplyTransformMatrices;fabric.util.object.extend(fabric.Object.prototype,{oCoords:null,intersectsWithRect:function(e,i){var r=t(this.oCoords),s=fabric.Intersection.intersectPolygonRectangle(r,e,i);return s.status==="Intersection"},intersectsWithObject:function(e){var i=fabric.Intersection.intersectPolygonPolygon(t(this.oCoords),t(e.oCoords));return i.status==="Intersection"},isContainedWithinObject:function(t){var e=t.getBoundingRect(),i=new fabric.Point(e.left,e.top),r=new fabric.Point(e.left+e.width,e.top+e.height);return this.isContainedWithinRect(i,r)},isContainedWithinRect:function(t,e){var i=this.getBoundingRect();return i.left>=t.x&&i.left+i.width<=e.x&&i.top>=t.y&&i.top+i.height<=e.y},containsPoint:function(t){var e=this._getImageLines(this.oCoords),i=this._findCrossPoints(t,e);return i!==0&&i%2===1},_getImageLines:function(t){return{topline:{o:t.tl,d:t.tr},rightline:{o:t.tr,d:t.br},bottomline:{o:t.br,d:t.bl},leftline:{o:t.bl,d:t.tl}}},_findCrossPoints:function(t,e){var i,r,s,n,o,a,h=0,c;for(var l in e){c=e[l];if(c.o.y<t.y&&c.d.y<t.y){continue}if(c.o.y>=t.y&&c.d.y>=t.y){continue}if(c.o.x===c.d.x&&c.o.x>=t.x){o=c.o.x;a=t.y}else{i=0;r=(c.d.y-c.o.y)/(c.d.x-c.o.x);s=t.y-i*t.x;n=c.o.y-r*c.o.x;o=-(s-n)/(i-r);a=s+i*o}if(o>=t.x){h+=1}if(h===2){break}}return h},getBoundingRectWidth:function(){return this.getBoundingRect().width},getBoundingRectHeight:function(){return this.getBoundingRect().height},getBoundingRect:function(){this.oCoords||this.setCoords();return fabric.util.makeBoundingBoxFromPoints([this.oCoords.tl,this.oCoords.tr,this.oCoords.br,this.oCoords.bl])},getWidth:function(){return this._getTransformedDimensions().x},getHeight:function(){return this._getTransformedDimensions().y},_constrainScale:function(t){if(Math.abs(t)<this.minScaleLimit){if(t<0){return-this.minScaleLimit}else{return this.minScaleLimit}}return t},scale:function(t){t=this._constrainScale(t);if(t<0){this.flipX=!this.flipX;this.flipY=!this.flipY;t*=-1}this.scaleX=t;this.scaleY=t;this.setCoords();return this},scaleToWidth:function(t){var e=this.getBoundingRect().width/this.getWidth();return this.scale(t/this.width/e)},scaleToHeight:function(t){var e=this.getBoundingRect().height/this.getHeight();return this.scale(t/this.height/e)},setCoords:function(){var t=e(this.angle),i=this.getViewportTransform(),r=this._calculateCurrentDimensions(),s=r.x,n=r.y;if(s<0){s=Math.abs(s)}var o=Math.sin(t),a=Math.cos(t),h=s>0?Math.atan(n/s):0,c=s/Math.cos(h)/2,l=Math.cos(h+t)*c,f=Math.sin(h+t)*c,u=fabric.util.transformPoint(this.getCenterPoint(),i),d=new fabric.Point(u.x-l,u.y-f),g=new fabric.Point(d.x+s*a,d.y+s*o),p=new fabric.Point(d.x-n*o,d.y+n*a),v=new fabric.Point(u.x+l,u.y+f),m=new fabric.Point((d.x+p.x)/2,(d.y+p.y)/2),b=new fabric.Point((g.x+d.x)/2,(g.y+d.y)/2),y=new fabric.Point((v.x+g.x)/2,(v.y+g.y)/2),_=new fabric.Point((v.x+p.x)/2,(v.y+p.y)/2),x=new fabric.Point(b.x+o*this.rotatingPointOffset,b.y-a*this.rotatingPointOffset);

this.oCoords={tl:d,tr:g,br:v,bl:p,ml:m,mt:b,mr:y,mb:_,mtr:x};this._setCornerCoords&&this._setCornerCoords();return this},_calcRotateMatrix:function(){if(this.angle){var t=e(this.angle),i=Math.cos(t),r=Math.sin(t);return[i,r,-r,i,0,0]}return[1,0,0,1,0,0]},calcTransformMatrix:function(){var t=this.getCenterPoint(),e=[1,0,0,1,t.x,t.y],r=this._calcRotateMatrix(),s=this._calcDimensionsTransformMatrix(this.skewX,this.skewY,true),n=this.group?this.group.calcTransformMatrix():[1,0,0,1,0,0];n=i(n,e);n=i(n,r);n=i(n,s);return n},_calcDimensionsTransformMatrix:function(t,r,s){var n=[1,0,Math.tan(e(t)),1],o=[1,Math.tan(e(r)),0,1],a=this.scaleX*(s&&this.flipX?-1:1),h=this.scaleY*(s&&this.flipY?-1:1),c=[a,0,0,h],l=i(c,n,true);return i(l,o,true)}})})();fabric.util.object.extend(fabric.Object.prototype,{sendToBack:function(){if(this.group){fabric.StaticCanvas.prototype.sendToBack.call(this.group,this)}else{this.canvas.sendToBack(this)}return this},bringToFront:function(){if(this.group){fabric.StaticCanvas.prototype.bringToFront.call(this.group,this)}else{this.canvas.bringToFront(this)}return this},sendBackwards:function(t){if(this.group){fabric.StaticCanvas.prototype.sendBackwards.call(this.group,this,t)}else{this.canvas.sendBackwards(this,t)}return this},bringForward:function(t){if(this.group){fabric.StaticCanvas.prototype.bringForward.call(this.group,this,t)}else{this.canvas.bringForward(this,t)}return this},moveTo:function(t){if(this.group){fabric.StaticCanvas.prototype.moveTo.call(this.group,this,t)}else{this.canvas.moveTo(this,t)}return this}});(function(){function t(t,e){if(!e){return t+": none; "}else if(e.toLive){return t+": url(#SVGID_"+e.id+"); "}else{var i=new fabric.Color(e),r=t+": "+e+"; ",s=i.getAlpha();if(s!==1){r=t+": "+i.toRgb()+"; ";r+=t+"-opacity: "+s.toString()+"; "}return r}}fabric.util.object.extend(fabric.Object.prototype,{getSvgStyles:function(e){var i=this.fillRule,r=this.strokeWidth?this.strokeWidth:"0",s=this.strokeDashArray?this.strokeDashArray.join(" "):"none",n=this.strokeLineCap?this.strokeLineCap:"butt",o=this.strokeLineJoin?this.strokeLineJoin:"miter",a=this.strokeMiterLimit?this.strokeMiterLimit:"4",h=typeof this.opacity!=="undefined"?this.opacity:"1",c=this.visible?"":" visibility: hidden;",l=e?"":this.getSvgFilter(),f=t("fill",this.fill),u=t("stroke",this.stroke);return[u,"stroke-width: ",r,"; ","stroke-dasharray: ",s,"; ","stroke-linecap: ",n,"; ","stroke-linejoin: ",o,"; ","stroke-miterlimit: ",a,"; ",f,"fill-rule: ",i,"; ","opacity: ",h,";",l,c].join("")},getSvgFilter:function(){return this.shadow?"filter: url(#SVGID_"+this.shadow.id+");":""},getSvgTransform:function(){if(this.group&&this.group.type==="path-group"){return""}var t=fabric.util.toFixed,e=this.getAngle(),i=this.getSkewX()%360,r=this.getSkewY()%360,s=this.getCenterPoint(),n=fabric.Object.NUM_FRACTION_DIGITS,o=this.type==="path-group"?"":"translate("+t(s.x,n)+" "+t(s.y,n)+")",a=e!==0?" rotate("+t(e,n)+")":"",h=this.scaleX===1&&this.scaleY===1?"":" scale("+t(this.scaleX,n)+" "+t(this.scaleY,n)+")",c=i!==0?" skewX("+t(i,n)+")":"",l=r!==0?" skewY("+t(r,n)+")":"",f=this.type==="path-group"?this.width:0,u=this.flipX?" matrix(-1 0 0 1 "+f+" 0) ":"",d=this.type==="path-group"?this.height:0,g=this.flipY?" matrix(1 0 0 -1 0 "+d+")":"";return[o,a,h,u,g,c,l].join("")},getSvgTransformMatrix:function(){return this.transformMatrix?" matrix("+this.transformMatrix.join(" ")+") ":""},_createBaseSVGMarkup:function(){var t=[];if(this.fill&&this.fill.toLive){t.push(this.fill.toSVG(this,false))}if(this.stroke&&this.stroke.toLive){t.push(this.stroke.toSVG(this,false))}if(this.shadow){t.push(this.shadow.toSVG(this))}return t}})})();fabric.util.object.extend(fabric.Object.prototype,{hasStateChanged:function(){return this.stateProperties.some(function(t){return this.get(t)!==this.originalState[t]},this)},saveState:function(t){this.stateProperties.forEach(function(t){this.originalState[t]=this.get(t)},this);if(t&&t.stateProperties){t.stateProperties.forEach(function(t){this.originalState[t]=this.get(t)},this)}return this},setupState:function(){this.originalState={};this.saveState();return this}});(function(){var t=fabric.util.degreesToRadians,e=function(){return typeof G_vmlCanvasManager!=="undefined"};fabric.util.object.extend(fabric.Object.prototype,{_controlsVisibility:null,_findTargetCorner:function(t){if(!this.hasControls||!this.active){return false}var e=t.x,i=t.y,r,s;this.__corner=0;for(var n in this.oCoords){if(!this.isControlVisible(n)){continue}if(n==="mtr"&&!this.hasRotatingPoint){continue}if(this.get("lockUniScaling")&&(n==="mt"||n==="mr"||n==="mb"||n==="ml")){continue}s=this._getImageLines(this.oCoords[n].corner);r=this._findCrossPoints({x:e,y:i},s);if(r!==0&&r%2===1){this.__corner=n;return n}}return false},_setCornerCoords:function(){var e=this.oCoords,i=t(45-this.angle),r=this.cornerSize*.707106,s=r*Math.cos(i),n=r*Math.sin(i),o,a;for(var h in e){o=e[h].x;a=e[h].y;e[h].corner={tl:{x:o-n,y:a-s},tr:{x:o+s,y:a-n},bl:{x:o-s,y:a+n},br:{x:o+n,y:a+s}}}},_getNonTransformedDimensions:function(){var t=this.strokeWidth,e=this.width,i=this.height,r=true,s=true;if(this.type==="line"&&this.strokeLineCap==="butt"){s=e;r=i}if(s){i+=i<0?-t:t}if(r){e+=e<0?-t:t}return{x:e,y:i}},_getTransformedDimensions:function(t,e){if(typeof t==="undefined"){t=this.skewX}if(typeof e==="undefined"){e=this.skewY}var i=this._getNonTransformedDimensions(),r=i.x/2,s=i.y/2,n=[{x:-r,y:-s},{x:r,y:-s},{x:-r,y:s},{x:r,y:s}],o,a=this._calcDimensionsTransformMatrix(t,e,false),h;for(o=0;o<n.length;o++){n[o]=fabric.util.transformPoint(n[o],a)}h=fabric.util.makeBoundingBoxFromPoints(n);return{x:h.width,y:h.height}},_calculateCurrentDimensions:function(){var t=this.getViewportTransform(),e=this._getTransformedDimensions(),i=e.x,r=e.y;i+=2*this.padding;r+=2*this.padding;return fabric.util.transformPoint(new fabric.Point(i,r),t,true)},drawSelectionBackground:function(e){if(!this.selectionBackgroundColor||!this.active||this.group){return this}e.save();var i=this.getCenterPoint(),r=this._calculateCurrentDimensions();e.translate(i.x,i.y);e.rotate(t(this.angle));e.fillStyle=this.selectionBackgroundColor;e.fillRect(-r.x/2,-r.y/2,r.x,r.y);e.restore();return this},drawBorders:function(t){if(!this.hasBorders){return this}var e=this._calculateCurrentDimensions(),i=1/this.borderScaleFactor,r=e.x+i,s=e.y+i;t.save();t.strokeStyle=this.borderColor;this._setLineDash(t,this.borderDashArray,null);t.strokeRect(-r/2,-s/2,r,s);if(this.hasRotatingPoint&&this.isControlVisible("mtr")&&!this.get("lockRotation")&&this.hasControls){var n=-s/2;t.beginPath();t.moveTo(0,n);t.lineTo(0,n-this.rotatingPointOffset);t.closePath();t.stroke()}t.restore();return this},drawBordersInGroup:function(t,e){if(!this.hasBorders){return this}var i=this._getNonTransformedDimensions(),r=fabric.util.customTransformMatrix(e.scaleX,e.scaleY,e.skewX),s=fabric.util.transformPoint(i,r),n=1/this.borderScaleFactor,o=s.x+n+2*this.padding,a=s.y+n+2*this.padding;t.save();this._setLineDash(t,this.borderDashArray,null);t.strokeStyle=this.borderColor;t.strokeRect(-o/2,-a/2,o,a);t.restore();return this},drawControls:function(t){if(!this.hasControls){return this}var e=this._calculateCurrentDimensions(),i=e.x,r=e.y,s=this.cornerSize,n=-(i+s)/2,o=-(r+s)/2,a=this.transparentCorners?"stroke":"fill";t.save();t.strokeStyle=t.fillStyle=this.cornerColor;if(!this.transparentCorners){t.strokeStyle=this.cornerStrokeColor}this._setLineDash(t,this.cornerDashArray,null);this._drawControl("tl",t,a,n,o);this._drawControl("tr",t,a,n+i,o);this._drawControl("bl",t,a,n,o+r);this._drawControl("br",t,a,n+i,o+r);if(!this.get("lockUniScaling")){this._drawControl("mt",t,a,n+i/2,o);this._drawControl("mb",t,a,n+i/2,o+r);this._drawControl("mr",t,a,n+i,o+r/2);this._drawControl("ml",t,a,n,o+r/2)}if(this.hasRotatingPoint){this._drawControl("mtr",t,a,n+i/2,o-this.rotatingPointOffset)}t.restore();return this},_drawControl:function(t,i,r,s,n){if(!this.isControlVisible(t)){return}var o=this.cornerSize,a=!this.transparentCorners&&this.cornerStrokeColor;switch(this.cornerStyle){case"circle":i.beginPath();i.arc(s+o/2,n+o/2,o/2,0,2*Math.PI,false);i[r]();if(a){i.stroke()}break;default:e()||this.transparentCorners||i.clearRect(s,n,o,o);i[r+"Rect"](s,n,o,o);if(a){i.strokeRect(s,n,o,o)}}},isControlVisible:function(t){return this._getControlsVisibility()[t]},setControlVisible:function(t,e){this._getControlsVisibility()[t]=e;return this},setControlsVisibility:function(t){t||(t={});for(var e in t){this.setControlVisible(e,t[e])}return this},_getControlsVisibility:function(){if(!this._controlsVisibility){this._controlsVisibility={tl:true,tr:true,br:true,bl:true,ml:true,mt:true,mr:true,mb:true,mtr:true}}return this._controlsVisibility}})})();fabric.util.object.extend(fabric.StaticCanvas.prototype,{FX_DURATION:500,fxCenterObjectH:function(t,e){e=e||{};var i=function(){},r=e.onComplete||i,s=e.onChange||i,n=this;fabric.util.animate({startValue:t.get("left"),endValue:this.getCenter().left,duration:this.FX_DURATION,onChange:function(e){t.set("left",e);n.renderAll();s()},onComplete:function(){t.setCoords();r()}});return this},fxCenterObjectV:function(t,e){e=e||{};var i=function(){},r=e.onComplete||i,s=e.onChange||i,n=this;fabric.util.animate({startValue:t.get("top"),endValue:this.getCenter().top,duration:this.FX_DURATION,onChange:function(e){t.set("top",e);n.renderAll();s()},onComplete:function(){t.setCoords();r()}});return this},fxRemove:function(t,e){e=e||{};var i=function(){},r=e.onComplete||i,s=e.onChange||i,n=this;fabric.util.animate({startValue:t.get("opacity"),endValue:0,duration:this.FX_DURATION,onStart:function(){t.set("active",false)},onChange:function(e){t.set("opacity",e);n.renderAll();s()},onComplete:function(){n.remove(t);r()}});return this}});fabric.util.object.extend(fabric.Object.prototype,{animate:function(){if(arguments[0]&&typeof arguments[0]==="object"){var t=[],e,i;for(e in arguments[0]){t.push(e)}for(var r=0,s=t.length;r<s;r++){e=t[r];i=r!==s-1;this._animate(e,arguments[0][e],arguments[1],i)}}else{this._animate.apply(this,arguments)}return this},_animate:function(t,e,i,r){var s=this,n;e=e.toString();if(!i){i={}}else{i=fabric.util.object.clone(i)}if(~t.indexOf(".")){n=t.split(".")}var o=n?this.get(n[0])[n[1]]:this.get(t);if(!("from"in i)){i.from=o}if(~e.indexOf("=")){e=o+parseFloat(e.replace("=",""))}else{e=parseFloat(e)}fabric.util.animate({startValue:i.from,endValue:e,byValue:i.by,easing:i.easing,duration:i.duration,abort:i.abort&&function(){return i.abort.call(s)},onChange:function(e){if(n){s[n[0]][n[1]]=e}else{s.set(t,e)}if(r){return}i.onChange&&i.onChange()},onComplete:function(){if(r){return}s.setCoords();i.onComplete&&i.onComplete()}})}});(function(t){"use strict";var e=t.fabric||(t.fabric={}),i=e.util.object.extend,r={x1:1,x2:1,y1:1,y2:1},s=e.StaticCanvas.supports("setLineDash");if(e.Line){e.warn("fabric.Line is already defined");return}e.Line=e.util.createClass(e.Object,{type:"line",x1:0,y1:0,x2:0,y2:0,initialize:function(t,e){e=e||{};if(!t){t=[0,0,0,0]}this.callSuper("initialize",e);this.set("x1",t[0]);this.set("y1",t[1]);this.set("x2",t[2]);this.set("y2",t[3]);this._setWidthHeight(e)},_setWidthHeight:function(t){t||(t={});this.width=Math.abs(this.x2-this.x1);this.height=Math.abs(this.y2-this.y1);this.left="left"in t?t.left:this._getLeftToOriginX();this.top="top"in t?t.top:this._getTopToOriginY()},_set:function(t,e){this.callSuper("_set",t,e);if(typeof r[t]!=="undefined"){this._setWidthHeight()}return this},_getLeftToOriginX:n({origin:"originX",axis1:"x1",axis2:"x2",dimension:"width"},{nearest:"left",center:"center",farthest:"right"}),_getTopToOriginY:n({origin:"originY",axis1:"y1",axis2:"y2",dimension:"height"},{nearest:"top",center:"center",farthest:"bottom"}),_render:function(t,e){t.beginPath();if(e){var i=this.getCenterPoint();t.translate(i.x-this.strokeWidth/2,i.y-this.strokeWidth/2)}if(!this.strokeDashArray||this.strokeDashArray&&s){var r=this.calcLinePoints();t.moveTo(r.x1,r.y1);t.lineTo(r.x2,r.y2)}t.lineWidth=this.strokeWidth;var n=t.strokeStyle;t.strokeStyle=this.stroke||t.fillStyle;this.stroke&&this._renderStroke(t);t.strokeStyle=n},_renderDashedStroke:function(t){var i=this.calcLinePoints();t.beginPath();e.util.drawDashedLine(t,i.x1,i.y1,i.x2,i.y2,this.strokeDashArray);t.closePath()},toObject:function(t){return i(this.callSuper("toObject",t),this.calcLinePoints())},calcLinePoints:function(){var t=this.x1<=this.x2?-1:1,e=this.y1<=this.y2?-1:1,i=t*this.width*.5,r=e*this.height*.5,s=t*this.width*-.5,n=e*this.height*-.5;return{x1:i,x2:s,y1:r,y2:n}},toSVG:function(t){var e=this._createBaseSVGMarkup(),i={x1:this.x1,x2:this.x2,y1:this.y1,y2:this.y2};if(!(this.group&&this.group.type==="path-group")){i=this.calcLinePoints()}e.push("<line ",'x1="',i.x1,'" y1="',i.y1,'" x2="',i.x2,'" y2="',i.y2,'" style="',this.getSvgStyles(),'" transform="',this.getSvgTransform(),this.getSvgTransformMatrix(),'"/>\n');return t?t(e.join("")):e.join("")},complexity:function(){return 1}});e.Line.ATTRIBUTE_NAMES=e.SHARED_ATTRIBUTES.concat("x1 y1 x2 y2".split(" "));e.Line.fromElement=function(t,r){var s=e.parseAttributes(t,e.Line.ATTRIBUTE_NAMES),n=[s.x1||0,s.y1||0,s.x2||0,s.y2||0];return new e.Line(n,i(s,r))};e.Line.fromObject=function(t){var i=[t.x1,t.y1,t.x2,t.y2];return new e.Line(i,t)};function n(t,e){var i=t.origin,r=t.axis1,s=t.axis2,n=t.dimension,o=e.nearest,a=e.center,h=e.farthest;return function(){switch(this.get(i)){case o:return Math.min(this.get(r),this.get(s));case a:return Math.min(this.get(r),this.get(s))+.5*this.get(n);case h:return Math.max(this.get(r),this.get(s))}}}})(typeof exports!=="undefined"?exports:this);(function(t){"use strict";var e=t.fabric||(t.fabric={}),i=Math.PI,r=e.util.object.extend;if(e.Circle){e.warn("fabric.Circle is already defined.");return}e.Circle=e.util.createClass(e.Object,{type:"circle",radius:0,startAngle:0,endAngle:i*2,initialize:function(t){t=t||{};this.callSuper("initialize",t);this.set("radius",t.radius||0);this.startAngle=t.startAngle||this.startAngle;this.endAngle=t.endAngle||this.endAngle},_set:function(t,e){this.callSuper("_set",t,e);if(t==="radius"){this.setRadius(e)}return this},toObject:function(t){return r(this.callSuper("toObject",t),{radius:this.get("radius"),startAngle:this.startAngle,endAngle:this.endAngle})},toSVG:function(t){var e=this._createBaseSVGMarkup(),r=0,s=0,n=(this.endAngle-this.startAngle)%(2*i);if(n===0){if(this.group&&this.group.type==="path-group"){r=this.left+this.radius;s=this.top+this.radius}e.push("<circle ",'cx="'+r+'" cy="'+s+'" ','r="',this.radius,'" style="',this.getSvgStyles(),'" transform="',this.getSvgTransform()," ",this.getSvgTransformMatrix(),'"/>\n')}else{var o=Math.cos(this.startAngle)*this.radius,a=Math.sin(this.startAngle)*this.radius,h=Math.cos(this.endAngle)*this.radius,c=Math.sin(this.endAngle)*this.radius,l=n>i?"1":"0";e.push('<path d="M '+o+" "+a," A "+this.radius+" "+this.radius," 0 ",+l+" 1"," "+h+" "+c,'" style="',this.getSvgStyles(),'" transform="',this.getSvgTransform()," ",this.getSvgTransformMatrix(),'"/>\n')}return t?t(e.join("")):e.join("")},_render:function(t,e){t.beginPath();t.arc(e?this.left+this.radius:0,e?this.top+this.radius:0,this.radius,this.startAngle,this.endAngle,false);this._renderFill(t);this._renderStroke(t)},getRadiusX:function(){return this.get("radius")*this.get("scaleX")},getRadiusY:function(){return this.get("radius")*this.get("scaleY")},setRadius:function(t){this.radius=t;return this.set("width",t*2).set("height",t*2)},complexity:function(){return 1}});e.Circle.ATTRIBUTE_NAMES=e.SHARED_ATTRIBUTES.concat("cx cy r".split(" "));e.Circle.fromElement=function(t,i){i||(i={});var n=e.parseAttributes(t,e.Circle.ATTRIBUTE_NAMES);if(!s(n)){throw new Error("value of `r` attribute is required and can not be negative")}n.left=n.left||0;n.top=n.top||0;var o=new e.Circle(r(n,i));o.left-=o.radius;o.top-=o.radius;return o};function s(t){return"radius"in t&&t.radius>=0}e.Circle.fromObject=function(t){return new e.Circle(t)}})(typeof exports!=="undefined"?exports:this);(function(t){"use strict";var e=t.fabric||(t.fabric={});if(e.Triangle){e.warn("fabric.Triangle is already defined");return}e.Triangle=e.util.createClass(e.Object,{type:"triangle",initialize:function(t){t=t||{};this.callSuper("initialize",t);this.set("width",t.width||100).set("height",t.height||100)},_render:function(t){var e=this.width/2,i=this.height/2;t.beginPath();t.moveTo(-e,i);t.lineTo(0,-i);t.lineTo(e,i);t.closePath();this._renderFill(t);this._renderStroke(t)},_renderDashedStroke:function(t){var i=this.width/2,r=this.height/2;t.beginPath();e.util.drawDashedLine(t,-i,r,0,-r,this.strokeDashArray);e.util.drawDashedLine(t,0,-r,i,r,this.strokeDashArray);e.util.drawDashedLine(t,i,r,-i,r,this.strokeDashArray);t.closePath()},toSVG:function(t){var e=this._createBaseSVGMarkup(),i=this.width/2,r=this.height/2,s=[-i+" "+r,"0 "+-r,i+" "+r].join(",");e.push("<polygon ",'points="',s,'" style="',this.getSvgStyles(),'" transform="',this.getSvgTransform(),'"/>');return t?t(e.join("")):e.join("")},complexity:function(){return 1}});e.Triangle.fromObject=function(t){return new e.Triangle(t)}})(typeof exports!=="undefined"?exports:this);(function(t){"use strict";var e=t.fabric||(t.fabric={}),i=Math.PI*2,r=e.util.object.extend;if(e.Ellipse){e.warn("fabric.Ellipse is already defined.");return}e.Ellipse=e.util.createClass(e.Object,{type:"ellipse",rx:0,ry:0,initialize:function(t){t=t||{};this.callSuper("initialize",t);this.set("rx",t.rx||0);this.set("ry",t.ry||0)},_set:function(t,e){this.callSuper("_set",t,e);switch(t){case"rx":this.rx=e;this.set("width",e*2);break;case"ry":this.ry=e;this.set("height",e*2);break}return this},getRx:function(){return this.get("rx")*this.get("scaleX")},getRy:function(){return this.get("ry")*this.get("scaleY")},toObject:function(t){return r(this.callSuper("toObject",t),{rx:this.get("rx"),ry:this.get("ry")})},toSVG:function(t){var e=this._createBaseSVGMarkup(),i=0,r=0;if(this.group&&this.group.type==="path-group"){i=this.left+this.rx;r=this.top+this.ry}e.push("<ellipse ",'cx="',i,'" cy="',r,'" ','rx="',this.rx,'" ry="',this.ry,'" style="',this.getSvgStyles(),'" transform="',this.getSvgTransform(),this.getSvgTransformMatrix(),'"/>\n');return t?t(e.join("")):e.join("")},_render:function(t,e){t.beginPath();t.save();t.transform(1,0,0,this.ry/this.rx,0,0);t.arc(e?this.left+this.rx:0,e?(this.top+this.ry)*this.rx/this.ry:0,this.rx,0,i,false);t.restore();this._renderFill(t);this._renderStroke(t)},complexity:function(){return 1}});e.Ellipse.ATTRIBUTE_NAMES=e.SHARED_ATTRIBUTES.concat("cx cy rx ry".split(" "));e.Ellipse.fromElement=function(t,i){i||(i={});var s=e.parseAttributes(t,e.Ellipse.ATTRIBUTE_NAMES);s.left=s.left||0;s.top=s.top||0;var n=new e.Ellipse(r(s,i));n.top-=n.ry;n.left-=n.rx;return n};e.Ellipse.fromObject=function(t){return new e.Ellipse(t)}})(typeof exports!=="undefined"?exports:this);(function(t){"use strict";var e=t.fabric||(t.fabric={}),i=e.util.object.extend;if(e.Rect){e.warn("fabric.Rect is already defined");return}var r=e.Object.prototype.stateProperties.concat();r.push("rx","ry","x","y");e.Rect=e.util.createClass(e.Object,{stateProperties:r,type:"rect",rx:0,ry:0,strokeDashArray:null,initialize:function(t){t=t||{};this.callSuper("initialize",t);this._initRxRy()},_initRxRy:function(){if(this.rx&&!this.ry){this.ry=this.rx}else if(this.ry&&!this.rx){this.rx=this.ry}},_render:function(t,e){if(this.width===1&&this.height===1){t.fillRect(-.5,-.5,1,1);return}var i=this.rx?Math.min(this.rx,this.width/2):0,r=this.ry?Math.min(this.ry,this.height/2):0,s=this.width,n=this.height,o=e?this.left:-this.width/2,a=e?this.top:-this.height/2,h=i!==0||r!==0,c=1-.5522847498;t.beginPath();t.moveTo(o+i,a);t.lineTo(o+s-i,a);h&&t.bezierCurveTo(o+s-c*i,a,o+s,a+c*r,o+s,a+r);t.lineTo(o+s,a+n-r);h&&t.bezierCurveTo(o+s,a+n-c*r,o+s-c*i,a+n,o+s-i,a+n);t.lineTo(o+i,a+n);h&&t.bezierCurveTo(o+c*i,a+n,o,a+n-c*r,o,a+n-r);t.lineTo(o,a+r);h&&t.bezierCurveTo(o,a+c*r,o+c*i,a,o+i,a);t.closePath();this._renderFill(t);this._renderStroke(t)},_renderDashedStroke:function(t){var i=-this.width/2,r=-this.height/2,s=this.width,n=this.height;t.beginPath();e.util.drawDashedLine(t,i,r,i+s,r,this.strokeDashArray);e.util.drawDashedLine(t,i+s,r,i+s,r+n,this.strokeDashArray);e.util.drawDashedLine(t,i+s,r+n,i,r+n,this.strokeDashArray);e.util.drawDashedLine(t,i,r+n,i,r,this.strokeDashArray);t.closePath()},toObject:function(t){var e=i(this.callSuper("toObject",t),{rx:this.get("rx")||0,ry:this.get("ry")||0});if(!this.includeDefaultValues){this._removeDefaultValues(e)}return e},toSVG:function(t){var e=this._createBaseSVGMarkup(),i=this.left,r=this.top;if(!(this.group&&this.group.type==="path-group")){i=-this.width/2;r=-this.height/2}e.push("<rect ",'x="',i,'" y="',r,'" rx="',this.get("rx"),'" ry="',this.get("ry"),'" width="',this.width,'" height="',this.height,'" style="',this.getSvgStyles(),'" transform="',this.getSvgTransform(),this.getSvgTransformMatrix(),'"/>\n');return t?t(e.join("")):e.join("")},complexity:function(){return 1}});e.Rect.ATTRIBUTE_NAMES=e.SHARED_ATTRIBUTES.concat("x y rx ry width height".split(" "));e.Rect.fromElement=function(t,r){if(!t){return null}r=r||{};var s=e.parseAttributes(t,e.Rect.ATTRIBUTE_NAMES);s.left=s.left||0;s.top=s.top||0;var n=new e.Rect(i(r?e.util.object.clone(r):{},s));n.visible=n.width>0&&n.height>0;return n};e.Rect.fromObject=function(t){return new e.Rect(t)}})(typeof exports!=="undefined"?exports:this);(function(t){"use strict";var e=t.fabric||(t.fabric={});if(e.Polyline){e.warn("fabric.Polyline is already defined");return}e.Polyline=e.util.createClass(e.Object,{type:"polyline",points:null,minX:0,minY:0,initialize:function(t,i){return e.Polygon.prototype.initialize.call(this,t,i)},_calcDimensions:function(){return e.Polygon.prototype._calcDimensions.call(this)},_applyPointOffset:function(){return e.Polygon.prototype._applyPointOffset.call(this)},toObject:function(t){return e.Polygon.prototype.toObject.call(this,t)},toSVG:function(t){return e.Polygon.prototype.toSVG.call(this,t)},_render:function(t,i){if(!e.Polygon.prototype.commonRender.call(this,t,i)){return}this._renderFill(t);this._renderStroke(t)},_renderDashedStroke:function(t){var i,r;t.beginPath();for(var s=0,n=this.points.length;s<n;s++){i=this.points[s];r=this.points[s+1]||i;e.util.drawDashedLine(t,i.x,i.y,r.x,r.y,this.strokeDashArray)}},complexity:function(){return this.get("points").length}});e.Polyline.ATTRIBUTE_NAMES=e.SHARED_ATTRIBUTES.concat();e.Polyline.fromElement=function(t,i){if(!t){return null}i||(i={});var r=e.parsePointsAttribute(t.getAttribute("points")),s=e.parseAttributes(t,e.Polyline.ATTRIBUTE_NAMES);return new e.Polyline(r,e.util.object.extend(s,i))};e.Polyline.fromObject=function(t){var i=t.points;return new e.Polyline(i,t,true)}})(typeof exports!=="undefined"?exports:this);(function(t){"use strict";var e=t.fabric||(t.fabric={}),i=e.util.object.extend,r=e.util.array.min,s=e.util.array.max,n=e.util.toFixed;if(e.Polygon){e.warn("fabric.Polygon is already defined");return}e.Polygon=e.util.createClass(e.Object,{type:"polygon",points:null,minX:0,minY:0,initialize:function(t,e){e=e||{};this.points=t||[];this.callSuper("initialize",e);this._calcDimensions();if(!("top"in e)){this.top=this.minY}if(!("left"in e)){this.left=this.minX}this.pathOffset={x:this.minX+this.width/2,y:this.minY+this.height/2}},_calcDimensions:function(){var t=this.points,e=r(t,"x"),i=r(t,"y"),n=s(t,"x"),o=s(t,"y");this.width=n-e||0;this.height=o-i||0;this.minX=e||0,this.minY=i||0},toObject:function(t){return i(this.callSuper("toObject",t),{points:this.points.concat()})},toSVG:function(t){var e=[],i,r=this._createBaseSVGMarkup();for(var s=0,o=this.points.length;s<o;s++){e.push(n(this.points[s].x,2),",",n(this.points[s].y,2)," ")}if(!(this.group&&this.group.type==="path-group")){i=" translate("+-this.pathOffset.x+", "+-this.pathOffset.y+") "}r.push("<",this.type," ",'points="',e.join(""),'" style="',this.getSvgStyles(),'" transform="',this.getSvgTransform(),i," ",this.getSvgTransformMatrix(),'"/>\n');return t?t(r.join("")):r.join("")},_render:function(t,e){if(!this.commonRender(t,e)){return}this._renderFill(t);if(this.stroke||this.strokeDashArray){t.closePath();this._renderStroke(t)}},commonRender:function(t,e){var i,r=this.points.length;if(!r||isNaN(this.points[r-1].y)){return false}e||t.translate(-this.pathOffset.x,-this.pathOffset.y);t.beginPath();t.moveTo(this.points[0].x,this.points[0].y);for(var s=0;s<r;s++){i=this.points[s];t.lineTo(i.x,i.y)}return true},_renderDashedStroke:function(t){e.Polyline.prototype._renderDashedStroke.call(this,t);t.closePath()},complexity:function(){return this.points.length}});e.Polygon.ATTRIBUTE_NAMES=e.SHARED_ATTRIBUTES.concat();e.Polygon.fromElement=function(t,r){if(!t){return null}r||(r={});var s=e.parsePointsAttribute(t.getAttribute("points")),n=e.parseAttributes(t,e.Polygon.ATTRIBUTE_NAMES);return new e.Polygon(s,i(n,r))};e.Polygon.fromObject=function(t){return new e.Polygon(t.points,t,true)}})(typeof exports!=="undefined"?exports:this);(function(t){"use strict";var e=t.fabric||(t.fabric={}),i=e.util.array.min,r=e.util.array.max,s=e.util.object.extend,n=Object.prototype.toString,o=e.util.drawArc,a={m:2,l:2,h:1,v:1,c:6,s:4,q:4,t:2,a:7},h={m:"l",M:"L"};if(e.Path){e.warn("fabric.Path is already defined");return}e.Path=e.util.createClass(e.Object,{type:"path",path:null,minX:0,minY:0,initialize:function(t,e){e=e||{};this.setOptions(e);if(!t){t=[]}var i=n.call(t)==="[object Array]";this.path=i?t:t.match&&t.match(/[mzlhvcsqta][^mzlhvcsqta]*/gi);if(!this.path){return}if(!i){this.path=this._parsePath()}this._setPositionDimensions(e);if(e.sourcePath){this.setSourcePath(e.sourcePath)}},_setPositionDimensions:function(t){var e=this._parseDimensions();this.minX=e.left;this.minY=e.top;this.width=e.width;this.height=e.height;if(typeof t.left==="undefined"){this.left=e.left+(this.originX==="center"?this.width/2:this.originX==="right"?this.width:0)}if(typeof t.top==="undefined"){this.top=e.top+(this.originY==="center"?this.height/2:this.originY==="bottom"?this.height:0)}this.pathOffset=this.pathOffset||{x:this.minX+this.width/2,y:this.minY+this.height/2}},_render:function(t){var e,i=null,r=0,s=0,n=0,a=0,h=0,c=0,l,f,u=-this.pathOffset.x,d=-this.pathOffset.y;if(this.group&&this.group.type==="path-group"){u=0;d=0}t.beginPath();for(var g=0,p=this.path.length;g<p;++g){e=this.path[g];switch(e[0]){case"l":n+=e[1];a+=e[2];t.lineTo(n+u,a+d);break;case"L":n=e[1];a=e[2];t.lineTo(n+u,a+d);break;case"h":n+=e[1];t.lineTo(n+u,a+d);break;case"H":n=e[1];t.lineTo(n+u,a+d);break;case"v":a+=e[1];t.lineTo(n+u,a+d);break;case"V":a=e[1];t.lineTo(n+u,a+d);break;case"m":n+=e[1];a+=e[2];r=n;s=a;t.moveTo(n+u,a+d);break;case"M":n=e[1];a=e[2];r=n;s=a;t.moveTo(n+u,a+d);break;case"c":l=n+e[5];f=a+e[6];h=n+e[3];c=a+e[4];t.bezierCurveTo(n+e[1]+u,a+e[2]+d,h+u,c+d,l+u,f+d);n=l;a=f;break;case"C":n=e[5];a=e[6];h=e[3];c=e[4];t.bezierCurveTo(e[1]+u,e[2]+d,h+u,c+d,n+u,a+d);break;case"s":l=n+e[3];f=a+e[4];if(i[0].match(/[CcSs]/)===null){h=n;c=a}else{h=2*n-h;c=2*a-c}t.bezierCurveTo(h+u,c+d,n+e[1]+u,a+e[2]+d,l+u,f+d);h=n+e[1];c=a+e[2];n=l;a=f;break;case"S":l=e[3];f=e[4];if(i[0].match(/[CcSs]/)===null){h=n;c=a}else{h=2*n-h;c=2*a-c}t.bezierCurveTo(h+u,c+d,e[1]+u,e[2]+d,l+u,f+d);n=l;a=f;h=e[1];c=e[2];break;case"q":l=n+e[3];f=a+e[4];h=n+e[1];c=a+e[2];t.quadraticCurveTo(h+u,c+d,l+u,f+d);n=l;a=f;break;case"Q":l=e[3];f=e[4];t.quadraticCurveTo(e[1]+u,e[2]+d,l+u,f+d);n=l;a=f;h=e[1];c=e[2];break;case"t":l=n+e[1];f=a+e[2];if(i[0].match(/[QqTt]/)===null){h=n;c=a}else{h=2*n-h;c=2*a-c}t.quadraticCurveTo(h+u,c+d,l+u,f+d);n=l;a=f;break;case"T":l=e[1];f=e[2];if(i[0].match(/[QqTt]/)===null){h=n;c=a}else{h=2*n-h;c=2*a-c}t.quadraticCurveTo(h+u,c+d,l+u,f+d);n=l;a=f;break;case"a":o(t,n+u,a+d,[e[1],e[2],e[3],e[4],e[5],e[6]+n+u,e[7]+a+d]);n+=e[6];a+=e[7];break;case"A":o(t,n+u,a+d,[e[1],e[2],e[3],e[4],e[5],e[6]+u,e[7]+d]);n=e[6];a=e[7];break;case"z":case"Z":n=r;a=s;t.closePath();break}i=e}this._renderFill(t);this._renderStroke(t)},toString:function(){return"#<fabric.Path ("+this.complexity()+'): { "top": '+this.top+', "left": '+this.left+" }>"},toObject:function(t){var e=s(this.callSuper("toObject",t),{path:this.path.map(function(t){return t.slice()}),pathOffset:this.pathOffset});if(this.sourcePath){e.sourcePath=this.sourcePath}if(this.transformMatrix){e.transformMatrix=this.transformMatrix}return e},toDatalessObject:function(t){var e=this.toObject(t);if(this.sourcePath){e.path=this.sourcePath}delete e.sourcePath;return e},toSVG:function(t){var e=[],i=this._createBaseSVGMarkup(),r="";for(var s=0,n=this.path.length;s<n;s++){e.push(this.path[s].join(" "))}var o=e.join(" ");if(!(this.group&&this.group.type==="path-group")){r=" translate("+-this.pathOffset.x+", "+-this.pathOffset.y+") "}i.push("<path ",'d="',o,'" style="',this.getSvgStyles(),'" transform="',this.getSvgTransform(),r,this.getSvgTransformMatrix(),'" stroke-linecap="round" ',"/>\n");return t?t(i.join("")):i.join("")},complexity:function(){return this.path.length},_parsePath:function(){var t=[],e=[],i,r,s=/([-+]?((\d+\.\d+)|((\d+)|(\.\d+)))(?:e[-+]?\d+)?)/gi,n,o;for(var c=0,l,f=this.path.length;c<f;c++){i=this.path[c];o=i.slice(1).trim();e.length=0;while(n=s.exec(o)){e.push(n[0])}l=[i.charAt(0)];for(var u=0,d=e.length;u<d;u++){r=parseFloat(e[u]);if(!isNaN(r)){l.push(r)}}var g=l[0],p=a[g.toLowerCase()],v=h[g]||g;if(l.length-1>p){for(var m=1,b=l.length;m<b;m+=p){t.push([g].concat(l.slice(m,m+p)));g=v}}else{t.push(l)}}return t},_parseDimensions:function(){var t=[],s=[],n,o=null,a=0,h=0,c=0,l=0,f=0,u=0,d,g,p;for(var v=0,m=this.path.length;v<m;++v){n=this.path[v];switch(n[0]){case"l":c+=n[1];l+=n[2];p=[];break;case"L":c=n[1];l=n[2];p=[];break;case"h":c+=n[1];p=[];break;case"H":c=n[1];p=[];break;case"v":l+=n[1];p=[];break;case"V":l=n[1];p=[];break;case"m":c+=n[1];l+=n[2];a=c;h=l;p=[];break;case"M":c=n[1];l=n[2];a=c;h=l;p=[];break;case"c":d=c+n[5];g=l+n[6];f=c+n[3];u=l+n[4];p=e.util.getBoundsOfCurve(c,l,c+n[1],l+n[2],f,u,d,g);c=d;l=g;break;case"C":c=n[5];l=n[6];f=n[3];u=n[4];p=e.util.getBoundsOfCurve(c,l,n[1],n[2],f,u,c,l);break;case"s":d=c+n[3];g=l+n[4];if(o[0].match(/[CcSs]/)===null){f=c;u=l}else{f=2*c-f;u=2*l-u}p=e.util.getBoundsOfCurve(c,l,f,u,c+n[1],l+n[2],d,g);f=c+n[1];u=l+n[2];c=d;l=g;break;case"S":d=n[3];g=n[4];if(o[0].match(/[CcSs]/)===null){f=c;u=l}else{f=2*c-f;u=2*l-u}p=e.util.getBoundsOfCurve(c,l,f,u,n[1],n[2],d,g);c=d;l=g;f=n[1];u=n[2];break;case"q":d=c+n[3];g=l+n[4];f=c+n[1];u=l+n[2];p=e.util.getBoundsOfCurve(c,l,f,u,f,u,d,g);c=d;l=g;break;case"Q":f=n[1];u=n[2];p=e.util.getBoundsOfCurve(c,l,f,u,f,u,n[3],n[4]);c=n[3];l=n[4];break;case"t":d=c+n[1];g=l+n[2];if(o[0].match(/[QqTt]/)===null){f=c;u=l}else{f=2*c-f;u=2*l-u}p=e.util.getBoundsOfCurve(c,l,f,u,f,u,d,g);c=d;l=g;break;case"T":d=n[1];g=n[2];if(o[0].match(/[QqTt]/)===null){f=c;u=l}else{f=2*c-f;u=2*l-u}p=e.util.getBoundsOfCurve(c,l,f,u,f,u,d,g);c=d;l=g;break;case"a":p=e.util.getBoundsOfArc(c,l,n[1],n[2],n[3],n[4],n[5],n[6]+c,n[7]+l);c+=n[6];l+=n[7];break;case"A":p=e.util.getBoundsOfArc(c,l,n[1],n[2],n[3],n[4],n[5],n[6],n[7]);c=n[6];l=n[7];break;case"z":case"Z":c=a;l=h;break}o=n;p.forEach(function(e){t.push(e.x);s.push(e.y)});t.push(c);s.push(l)}var b=i(t)||0,y=i(s)||0,_=r(t)||0,x=r(s)||0,S=_-b,C=x-y,w={left:b,top:y,width:S,height:C};return w}});e.Path.fromObject=function(t,i){if(typeof t.path==="string"){e.loadSVGFromURL(t.path,function(r){var s=r[0],n=t.path;delete t.path;e.util.object.extend(s,t);s.setSourcePath(n);i(s)})}else{i(new e.Path(t.path,t))}};e.Path.ATTRIBUTE_NAMES=e.SHARED_ATTRIBUTES.concat(["d"]);e.Path.fromElement=function(t,i,r){var n=e.parseAttributes(t,e.Path.ATTRIBUTE_NAMES);i&&i(new e.Path(n.d,s(n,r)))};e.Path.async=true})(typeof exports!=="undefined"?exports:this);(function(t){"use strict";var e=t.fabric||(t.fabric={}),i=e.util.object.extend,r=e.util.array.invoke,s=e.Object.prototype.toObject;if(e.PathGroup){e.warn("fabric.PathGroup is already defined");return}e.PathGroup=e.util.createClass(e.Path,{type:"path-group",fill:"",initialize:function(t,e){e=e||{};this.paths=t||[];

for(var i=this.paths.length;i--;){this.paths[i].group=this}if(e.toBeParsed){this.parseDimensionsFromPaths(e);delete e.toBeParsed}this.setOptions(e);this.setCoords();if(e.sourcePath){this.setSourcePath(e.sourcePath)}},parseDimensionsFromPaths:function(t){var i,r,s=[],n=[],o,a,h,c;for(var l=this.paths.length;l--;){o=this.paths[l];a=o.height+o.strokeWidth;h=o.width+o.strokeWidth;i=[{x:o.left,y:o.top},{x:o.left+h,y:o.top},{x:o.left,y:o.top+a},{x:o.left+h,y:o.top+a}];c=this.paths[l].transformMatrix;for(var f=0;f<i.length;f++){r=i[f];if(c){r=e.util.transformPoint(r,c,false)}s.push(r.x);n.push(r.y)}}t.width=Math.max.apply(null,s);t.height=Math.max.apply(null,n)},render:function(t){if(!this.visible){return}t.save();if(this.transformMatrix){t.transform.apply(t,this.transformMatrix)}this.transform(t);this._setShadow(t);this.clipTo&&e.util.clipContext(this,t);t.translate(-this.width/2,-this.height/2);for(var i=0,r=this.paths.length;i<r;++i){this.paths[i].render(t,true)}this.clipTo&&t.restore();t.restore()},_set:function(t,e){if(t==="fill"&&e&&this.isSameColor()){var i=this.paths.length;while(i--){this.paths[i]._set(t,e)}}return this.callSuper("_set",t,e)},toObject:function(t){var e=i(s.call(this,t),{paths:r(this.getObjects(),"toObject",t)});if(this.sourcePath){e.sourcePath=this.sourcePath}return e},toDatalessObject:function(t){var e=this.toObject(t);if(this.sourcePath){e.paths=this.sourcePath}return e},toSVG:function(t){var e=this.getObjects(),i=this.getPointByOrigin("left","top"),r="translate("+i.x+" "+i.y+")",s=this._createBaseSVGMarkup();s.push("<g ",'style="',this.getSvgStyles(),'" ','transform="',this.getSvgTransformMatrix(),r,this.getSvgTransform(),'" ',">\n");for(var n=0,o=e.length;n<o;n++){s.push("	",e[n].toSVG(t))}s.push("</g>\n");return t?t(s.join("")):s.join("")},toString:function(){return"#<fabric.PathGroup ("+this.complexity()+"): { top: "+this.top+", left: "+this.left+" }>"},isSameColor:function(){var t=this.getObjects()[0].get("fill")||"";if(typeof t!=="string"){return false}t=t.toLowerCase();return this.getObjects().every(function(e){var i=e.get("fill")||"";return typeof i==="string"&&i.toLowerCase()===t})},complexity:function(){return this.paths.reduce(function(t,e){return t+(e&&e.complexity?e.complexity():0)},0)},getObjects:function(){return this.paths}});e.PathGroup.fromObject=function(t,i){if(typeof t.paths==="string"){e.loadSVGFromURL(t.paths,function(r){var s=t.paths;delete t.paths;var n=e.util.groupSVGElements(r,t,s);i(n)})}else{e.util.enlivenObjects(t.paths,function(r){delete t.paths;i(new e.PathGroup(r,t))})}};e.PathGroup.async=true})(typeof exports!=="undefined"?exports:this);(function(t){"use strict";var e=t.fabric||(t.fabric={}),i=e.util.object.extend,r=e.util.array.min,s=e.util.array.max,n=e.util.array.invoke;if(e.Group){return}var o={lockMovementX:true,lockMovementY:true,lockRotation:true,lockScalingX:true,lockScalingY:true,lockUniScaling:true};e.Group=e.util.createClass(e.Object,e.Collection,{type:"group",strokeWidth:0,initialize:function(t,e,i){e=e||{};this._objects=[];i&&this.callSuper("initialize",e);this._objects=t||[];for(var r=this._objects.length;r--;){this._objects[r].group=this}this.originalState={};if(e.originX){this.originX=e.originX}if(e.originY){this.originY=e.originY}if(i){this._updateObjectsCoords(true)}else{this._calcBounds();this._updateObjectsCoords();this.callSuper("initialize",e)}this.setCoords();this.saveCoords()},_updateObjectsCoords:function(t){for(var e=this._objects.length;e--;){this._updateObjectCoords(this._objects[e],t)}},_updateObjectCoords:function(t,e){t.__origHasControls=t.hasControls;t.hasControls=false;if(e){return}var i=t.getLeft(),r=t.getTop(),s=this.getCenterPoint();t.set({originalLeft:i,originalTop:r,left:i-s.x,top:r-s.y});t.setCoords()},toString:function(){return"#<fabric.Group: ("+this.complexity()+")>"},addWithUpdate:function(t){this._restoreObjectsState();e.util.resetObjectTransform(this);if(t){this._objects.push(t);t.group=this;t._set("canvas",this.canvas)}this.forEachObject(this._setObjectActive,this);this._calcBounds();this._updateObjectsCoords();return this},_setObjectActive:function(t){t.set("active",true);t.group=this},removeWithUpdate:function(t){this._restoreObjectsState();e.util.resetObjectTransform(this);this.forEachObject(this._setObjectActive,this);this.remove(t);this._calcBounds();this._updateObjectsCoords();return this},_onObjectAdded:function(t){t.group=this;t._set("canvas",this.canvas)},_onObjectRemoved:function(t){delete t.group;t.set("active",false)},delegatedProperties:{fill:true,stroke:true,strokeWidth:true,fontFamily:true,fontWeight:true,fontSize:true,fontStyle:true,lineHeight:true,textDecoration:true,textAlign:true,backgroundColor:true},_set:function(t,e){var i=this._objects.length;if(this.delegatedProperties[t]||t==="canvas"){while(i--){this._objects[i].set(t,e)}}else{while(i--){this._objects[i].setOnGroup(t,e)}}this.callSuper("_set",t,e)},toObject:function(t){return i(this.callSuper("toObject",t),{objects:n(this._objects,"toObject",t)})},render:function(t){if(!this.visible){return}t.save();if(this.transformMatrix){t.transform.apply(t,this.transformMatrix)}this.transform(t);this._setShadow(t);this.clipTo&&e.util.clipContext(this,t);for(var i=0,r=this._objects.length;i<r;i++){this._renderObject(this._objects[i],t)}this.clipTo&&t.restore();t.restore()},_renderControls:function(t,e){this.callSuper("_renderControls",t,e);for(var i=0,r=this._objects.length;i<r;i++){this._objects[i]._renderControls(t)}},_renderObject:function(t,e){if(!t.visible){return}var i=t.hasRotatingPoint;t.hasRotatingPoint=false;t.render(e);t.hasRotatingPoint=i},_restoreObjectsState:function(){this._objects.forEach(this._restoreObjectState,this);return this},realizeTransform:function(t){var i=t.calcTransformMatrix(),r=e.util.qrDecompose(i),s=new e.Point(r.translateX,r.translateY);t.scaleX=r.scaleX;t.scaleY=r.scaleY;t.skewX=r.skewX;t.skewY=r.skewY;t.angle=r.angle;t.flipX=false;t.flipY=false;t.setPositionByOrigin(s,"center","center");return t},_restoreObjectState:function(t){this.realizeTransform(t);t.setCoords();t.hasControls=t.__origHasControls;delete t.__origHasControls;t.set("active",false);delete t.group;return this},destroy:function(){return this._restoreObjectsState()},saveCoords:function(){this._originalLeft=this.get("left");this._originalTop=this.get("top");return this},hasMoved:function(){return this._originalLeft!==this.get("left")||this._originalTop!==this.get("top")},setObjectsCoords:function(){this.forEachObject(function(t){t.setCoords()});return this},_calcBounds:function(t){var e=[],i=[],r,s,n=["tr","br","bl","tl"],o=0,a=this._objects.length,h,c=n.length;for(;o<a;++o){r=this._objects[o];r.setCoords();for(h=0;h<c;h++){s=n[h];e.push(r.oCoords[s].x);i.push(r.oCoords[s].y)}}this.set(this._getBounds(e,i,t))},_getBounds:function(t,i,n){var o=e.util.invertTransform(this.getViewportTransform()),a=e.util.transformPoint(new e.Point(r(t),r(i)),o),h=e.util.transformPoint(new e.Point(s(t),s(i)),o),c={width:h.x-a.x||0,height:h.y-a.y||0};if(!n){c.left=a.x||0;c.top=a.y||0;if(this.originX==="center"){c.left+=c.width/2}if(this.originX==="right"){c.left+=c.width}if(this.originY==="center"){c.top+=c.height/2}if(this.originY==="bottom"){c.top+=c.height}}return c},toSVG:function(t){var e=this._createBaseSVGMarkup();e.push('<g transform="',this.getSvgTransform(),this.getSvgTransformMatrix(),'" style="',this.getSvgFilter(),'">\n');for(var i=0,r=this._objects.length;i<r;i++){e.push("	",this._objects[i].toSVG(t))}e.push("</g>\n");return t?t(e.join("")):e.join("")},get:function(t){if(t in o){if(this[t]){return this[t]}else{for(var e=0,i=this._objects.length;e<i;e++){if(this._objects[e][t]){return true}}return false}}else{if(t in this.delegatedProperties){return this._objects[0]&&this._objects[0].get(t)}return this[t]}}});e.Group.fromObject=function(t,i){e.util.enlivenObjects(t.objects,function(r){delete t.objects;i&&i(new e.Group(r,t,true))})};e.Group.async=true})(typeof exports!=="undefined"?exports:this);(function(t){"use strict";var e=fabric.util.object.extend;if(!t.fabric){t.fabric={}}if(t.fabric.Image){fabric.warn("fabric.Image is already defined.");return}fabric.Image=fabric.util.createClass(fabric.Object,{type:"image",crossOrigin:"",alignX:"none",alignY:"none",meetOrSlice:"meet",strokeWidth:0,_lastScaleX:1,_lastScaleY:1,initialize:function(t,e){e||(e={});this.filters=[];this.resizeFilters=[];this.callSuper("initialize",e);this._initElement(t,e)},getElement:function(){return this._element},setElement:function(t,e,i){this._element=t;this._originalElement=t;this._initConfig(i);if(this.filters.length!==0){this.applyFilters(e)}else if(e){e()}return this},setCrossOrigin:function(t){this.crossOrigin=t;this._element.crossOrigin=t;return this},getOriginalSize:function(){var t=this.getElement();return{width:t.width,height:t.height}},_stroke:function(t){if(!this.stroke||this.strokeWidth===0){return}var e=this.width/2,i=this.height/2;t.beginPath();t.moveTo(-e,-i);t.lineTo(e,-i);t.lineTo(e,i);t.lineTo(-e,i);t.lineTo(-e,-i);t.closePath()},_renderDashedStroke:function(t){var e=-this.width/2,i=-this.height/2,r=this.width,s=this.height;t.save();this._setStrokeStyles(t);t.beginPath();fabric.util.drawDashedLine(t,e,i,e+r,i,this.strokeDashArray);fabric.util.drawDashedLine(t,e+r,i,e+r,i+s,this.strokeDashArray);fabric.util.drawDashedLine(t,e+r,i+s,e,i+s,this.strokeDashArray);fabric.util.drawDashedLine(t,e,i+s,e,i,this.strokeDashArray);t.closePath();t.restore()},toObject:function(t){var i=[],r=[],s=this._originalElement,n=1,o=1;this.filters.forEach(function(t){if(t){if(t.type==="Resize"){n*=t.scaleX;o*=t.scaleY}i.push(t.toObject())}});this.resizeFilters.forEach(function(t){t&&r.push(t.toObject())});var a=e(this.callSuper("toObject",t),{src:s?s.src||s._src:"",filters:i,resizeFilters:r,crossOrigin:this.crossOrigin,alignX:this.alignX,alignY:this.alignY,meetOrSlice:this.meetOrSlice});a.width/=n;a.height/=o;if(!this.includeDefaultValues){this._removeDefaultValues(a)}return a},toSVG:function(t){var e=this._createBaseSVGMarkup(),i=-this.width/2,r=-this.height/2,s="none";if(this.group&&this.group.type==="path-group"){i=this.left;r=this.top}if(this.alignX!=="none"&&this.alignY!=="none"){s="x"+this.alignX+"Y"+this.alignY+" "+this.meetOrSlice}e.push('<g transform="',this.getSvgTransform(),this.getSvgTransformMatrix(),'">\n','<image xlink:href="',this.getSvgSrc(),'" x="',i,'" y="',r,'" style="',this.getSvgStyles(),'" width="',this.width,'" height="',this.height,'" preserveAspectRatio="',s,'"',"></image>\n");if(this.stroke||this.strokeDashArray){var n=this.fill;this.fill=null;e.push("<rect ",'x="',i,'" y="',r,'" width="',this.width,'" height="',this.height,'" style="',this.getSvgStyles(),'"/>\n');this.fill=n}e.push("</g>\n");return t?t(e.join("")):e.join("")},getSrc:function(){if(this.getElement()){return this.getElement().src||this.getElement()._src}},setSrc:function(t,e,i){fabric.util.loadImage(t,function(t){return this.setElement(t,e,i)},this,i&&i.crossOrigin)},toString:function(){return'#<fabric.Image: { src: "'+this.getSrc()+'" }>'},clone:function(t,e){this.constructor.fromObject(this.toObject(e),t)},applyFilters:function(t,e,i,r){e=e||this.filters;i=i||this._originalElement;if(!i){return}var s=i,n=fabric.util.createCanvasElement(),o=fabric.util.createImage(),a=this;n.width=s.width;n.height=s.height;n.getContext("2d").drawImage(s,0,0,s.width,s.height);if(e.length===0){this._element=i;t&&t();return n}e.forEach(function(t){t&&t.applyTo(n,t.scaleX||a.scaleX,t.scaleY||a.scaleY);if(!r&&t&&t.type==="Resize"){a.width*=t.scaleX;a.height*=t.scaleY}});o.width=n.width;o.height=n.height;if(fabric.isLikelyNode){o.src=n.toBuffer(undefined,fabric.Image.pngCompression);a._element=o;!r&&(a._filteredEl=o);t&&t()}else{o.onload=function(){a._element=o;!r&&(a._filteredEl=o);t&&t();o.onload=n=s=null};o.src=n.toDataURL("image/png")}return n},_render:function(t,e){var i,r,s=this._findMargins(),n;i=e?this.left:-this.width/2;r=e?this.top:-this.height/2;if(this.meetOrSlice==="slice"){t.beginPath();t.rect(i,r,this.width,this.height);t.clip()}if(this.isMoving===false&&this.resizeFilters.length&&this._needsResize()){this._lastScaleX=this.scaleX;this._lastScaleY=this.scaleY;n=this.applyFilters(null,this.resizeFilters,this._filteredEl||this._originalElement,true)}else{n=this._element}n&&t.drawImage(n,i+s.marginX,r+s.marginY,s.width,s.height);this._stroke(t);this._renderStroke(t)},_needsResize:function(){return this.scaleX!==this._lastScaleX||this.scaleY!==this._lastScaleY},_findMargins:function(){var t=this.width,e=this.height,i,r,s=0,n=0;if(this.alignX!=="none"||this.alignY!=="none"){i=[this.width/this._element.width,this.height/this._element.height];r=this.meetOrSlice==="meet"?Math.min.apply(null,i):Math.max.apply(null,i);t=this._element.width*r;e=this._element.height*r;if(this.alignX==="Mid"){s=(this.width-t)/2}if(this.alignX==="Max"){s=this.width-t}if(this.alignY==="Mid"){n=(this.height-e)/2}if(this.alignY==="Max"){n=this.height-e}}return{width:t,height:e,marginX:s,marginY:n}},_resetWidthHeight:function(){var t=this.getElement();this.set("width",t.width);this.set("height",t.height)},_initElement:function(t,e){this.setElement(fabric.util.getById(t),null,e);fabric.util.addClass(this.getElement(),fabric.Image.CSS_CANVAS)},_initConfig:function(t){t||(t={});this.setOptions(t);this._setWidthHeight(t);if(this._element&&this.crossOrigin){this._element.crossOrigin=this.crossOrigin}},_initFilters:function(t,e){if(t&&t.length){fabric.util.enlivenObjects(t,function(t){e&&e(t)},"fabric.Image.filters")}else{e&&e()}},_setWidthHeight:function(t){this.width="width"in t?t.width:this.getElement()?this.getElement().width||0:0;this.height="height"in t?t.height:this.getElement()?this.getElement().height||0:0},complexity:function(){return 1}});fabric.Image.CSS_CANVAS="canvas-img";fabric.Image.prototype.getSvgSrc=fabric.Image.prototype.getSrc;fabric.Image.fromObject=function(t,e){fabric.util.loadImage(t.src,function(i){fabric.Image.prototype._initFilters.call(t,t.filters,function(r){t.filters=r||[];fabric.Image.prototype._initFilters.call(t,t.resizeFilters,function(r){t.resizeFilters=r||[];var s=new fabric.Image(i,t);e&&e(s)})})},null,t.crossOrigin)};fabric.Image.fromURL=function(t,e,i){fabric.util.loadImage(t,function(t){e&&e(new fabric.Image(t,i))},null,i&&i.crossOrigin)};fabric.Image.ATTRIBUTE_NAMES=fabric.SHARED_ATTRIBUTES.concat("x y width height preserveAspectRatio xlink:href".split(" "));fabric.Image.fromElement=function(t,i,r){var s=fabric.parseAttributes(t,fabric.Image.ATTRIBUTE_NAMES),n;if(s.preserveAspectRatio){n=fabric.util.parsePreserveAspectRatioAttribute(s.preserveAspectRatio);e(s,n)}fabric.Image.fromURL(s["xlink:href"],i,e(r?fabric.util.object.clone(r):{},s))};fabric.Image.async=true;fabric.Image.pngCompression=1})(typeof exports!=="undefined"?exports:this);fabric.util.object.extend(fabric.Object.prototype,{_getAngleValueForStraighten:function(){var t=this.getAngle()%360;if(t>0){return Math.round((t-1)/90)*90}return Math.round(t/90)*90},straighten:function(){this.setAngle(this._getAngleValueForStraighten());return this},fxStraighten:function(t){t=t||{};var e=function(){},i=t.onComplete||e,r=t.onChange||e,s=this;fabric.util.animate({startValue:this.get("angle"),endValue:this._getAngleValueForStraighten(),duration:this.FX_DURATION,onChange:function(t){s.setAngle(t);r()},onComplete:function(){s.setCoords();i()},onStart:function(){s.set("active",false)}});return this}});fabric.util.object.extend(fabric.StaticCanvas.prototype,{straightenObject:function(t){t.straighten();this.renderAll();return this},fxStraightenObject:function(t){t.fxStraighten({onChange:this.renderAll.bind(this)});return this}});fabric.Image.filters=fabric.Image.filters||{};fabric.Image.filters.BaseFilter=fabric.util.createClass({type:"BaseFilter",initialize:function(t){if(t){this.setOptions(t)}},setOptions:function(t){for(var e in t){this[e]=t[e]}},toObject:function(){return{type:this.type}},toJSON:function(){return this.toObject()}});(function(t){"use strict";var e=t.fabric||(t.fabric={}),i=e.util.object.extend;e.Image.filters.Brightness=e.util.createClass(e.Image.filters.BaseFilter,{type:"Brightness",initialize:function(t){t=t||{};this.brightness=t.brightness||0},applyTo:function(t){var e=t.getContext("2d"),i=e.getImageData(0,0,t.width,t.height),r=i.data,s=this.brightness;for(var n=0,o=r.length;n<o;n+=4){r[n]+=s;r[n+1]+=s;r[n+2]+=s}e.putImageData(i,0,0)},toObject:function(){return i(this.callSuper("toObject"),{brightness:this.brightness})}});e.Image.filters.Brightness.fromObject=function(t){return new e.Image.filters.Brightness(t)}})(typeof exports!=="undefined"?exports:this);(function(t){"use strict";var e=t.fabric||(t.fabric={}),i=e.util.object.extend;e.Image.filters.Convolute=e.util.createClass(e.Image.filters.BaseFilter,{type:"Convolute",initialize:function(t){t=t||{};this.opaque=t.opaque;this.matrix=t.matrix||[0,0,0,0,1,0,0,0,0]},applyTo:function(t){var e=this.matrix,i=t.getContext("2d"),r=i.getImageData(0,0,t.width,t.height),s=Math.round(Math.sqrt(e.length)),n=Math.floor(s/2),o=r.data,a=r.width,h=r.height,c=i.createImageData(a,h),l=c.data,f=this.opaque?1:0,u,d,g,p,v,m,b,y,_;for(var x=0;x<h;x++){for(var S=0;S<a;S++){v=(x*a+S)*4;u=0;d=0;g=0;p=0;for(var C=0;C<s;C++){for(var w=0;w<s;w++){b=x+C-n;m=S+w-n;if(b<0||b>h||m<0||m>a){continue}y=(b*a+m)*4;_=e[C*s+w];u+=o[y]*_;d+=o[y+1]*_;g+=o[y+2]*_;p+=o[y+3]*_}}l[v]=u;l[v+1]=d;l[v+2]=g;l[v+3]=p+f*(255-p)}}i.putImageData(c,0,0)},toObject:function(){return i(this.callSuper("toObject"),{opaque:this.opaque,matrix:this.matrix})}});e.Image.filters.Convolute.fromObject=function(t){return new e.Image.filters.Convolute(t)}})(typeof exports!=="undefined"?exports:this);(function(t){"use strict";var e=t.fabric||(t.fabric={}),i=e.util.object.extend;e.Image.filters.GradientTransparency=e.util.createClass(e.Image.filters.BaseFilter,{type:"GradientTransparency",initialize:function(t){t=t||{};this.threshold=t.threshold||100},applyTo:function(t){var e=t.getContext("2d"),i=e.getImageData(0,0,t.width,t.height),r=i.data,s=this.threshold,n=r.length;for(var o=0,a=r.length;o<a;o+=4){r[o+3]=s+255*(n-o)/n}e.putImageData(i,0,0)},toObject:function(){return i(this.callSuper("toObject"),{threshold:this.threshold})}});e.Image.filters.GradientTransparency.fromObject=function(t){return new e.Image.filters.GradientTransparency(t)}})(typeof exports!=="undefined"?exports:this);(function(t){"use strict";var e=t.fabric||(t.fabric={});e.Image.filters.Grayscale=e.util.createClass(e.Image.filters.BaseFilter,{type:"Grayscale",applyTo:function(t){var e=t.getContext("2d"),i=e.getImageData(0,0,t.width,t.height),r=i.data,s=i.width*i.height*4,n=0,o;while(n<s){o=(r[n]+r[n+1]+r[n+2])/3;r[n]=o;r[n+1]=o;r[n+2]=o;n+=4}e.putImageData(i,0,0)}});e.Image.filters.Grayscale.fromObject=function(){return new e.Image.filters.Grayscale}})(typeof exports!=="undefined"?exports:this);(function(t){"use strict";var e=t.fabric||(t.fabric={});e.Image.filters.Invert=e.util.createClass(e.Image.filters.BaseFilter,{type:"Invert",applyTo:function(t){var e=t.getContext("2d"),i=e.getImageData(0,0,t.width,t.height),r=i.data,s=r.length,n;for(n=0;n<s;n+=4){r[n]=255-r[n];r[n+1]=255-r[n+1];r[n+2]=255-r[n+2]}e.putImageData(i,0,0)}});e.Image.filters.Invert.fromObject=function(){return new e.Image.filters.Invert}})(typeof exports!=="undefined"?exports:this);(function(t){"use strict";var e=t.fabric||(t.fabric={}),i=e.util.object.extend;e.Image.filters.Mask=e.util.createClass(e.Image.filters.BaseFilter,{type:"Mask",initialize:function(t){t=t||{};this.mask=t.mask;this.channel=[0,1,2,3].indexOf(t.channel)>-1?t.channel:0},applyTo:function(t){if(!this.mask){return}var i=t.getContext("2d"),r=i.getImageData(0,0,t.width,t.height),s=r.data,n=this.mask.getElement(),o=e.util.createCanvasElement(),a=this.channel,h,c=r.width*r.height*4;o.width=t.width;o.height=t.height;o.getContext("2d").drawImage(n,0,0,t.width,t.height);var l=o.getContext("2d").getImageData(0,0,t.width,t.height),f=l.data;for(h=0;h<c;h+=4){s[h+3]=f[h+a]}i.putImageData(r,0,0)},toObject:function(){return i(this.callSuper("toObject"),{mask:this.mask.toObject(),channel:this.channel})}});e.Image.filters.Mask.fromObject=function(t,i){e.util.loadImage(t.mask.src,function(r){t.mask=new e.Image(r,t.mask);i&&i(new e.Image.filters.Mask(t))})};e.Image.filters.Mask.async=true})(typeof exports!=="undefined"?exports:this);(function(t){"use strict";var e=t.fabric||(t.fabric={}),i=e.util.object.extend;e.Image.filters.Noise=e.util.createClass(e.Image.filters.BaseFilter,{type:"Noise",initialize:function(t){t=t||{};this.noise=t.noise||0},applyTo:function(t){var e=t.getContext("2d"),i=e.getImageData(0,0,t.width,t.height),r=i.data,s=this.noise,n;for(var o=0,a=r.length;o<a;o+=4){n=(.5-Math.random())*s;r[o]+=n;r[o+1]+=n;r[o+2]+=n}e.putImageData(i,0,0)},toObject:function(){return i(this.callSuper("toObject"),{noise:this.noise})}});e.Image.filters.Noise.fromObject=function(t){return new e.Image.filters.Noise(t)}})(typeof exports!=="undefined"?exports:this);(function(t){"use strict";var e=t.fabric||(t.fabric={}),i=e.util.object.extend;e.Image.filters.Pixelate=e.util.createClass(e.Image.filters.BaseFilter,{type:"Pixelate",initialize:function(t){t=t||{};this.blocksize=t.blocksize||4},applyTo:function(t){var e=t.getContext("2d"),i=e.getImageData(0,0,t.width,t.height),r=i.data,s=i.height,n=i.width,o,a,h,c,l,f,u;for(a=0;a<s;a+=this.blocksize){for(h=0;h<n;h+=this.blocksize){o=a*4*n+h*4;c=r[o];l=r[o+1];f=r[o+2];u=r[o+3];for(var d=a,g=a+this.blocksize;d<g;d++){for(var p=h,v=h+this.blocksize;p<v;p++){o=d*4*n+p*4;r[o]=c;r[o+1]=l;r[o+2]=f;r[o+3]=u}}}}e.putImageData(i,0,0)},toObject:function(){return i(this.callSuper("toObject"),{blocksize:this.blocksize})}});e.Image.filters.Pixelate.fromObject=function(t){return new e.Image.filters.Pixelate(t)}})(typeof exports!=="undefined"?exports:this);(function(t){"use strict";var e=t.fabric||(t.fabric={}),i=e.util.object.extend;e.Image.filters.RemoveWhite=e.util.createClass(e.Image.filters.BaseFilter,{type:"RemoveWhite",initialize:function(t){t=t||{};this.threshold=t.threshold||30;this.distance=t.distance||20},applyTo:function(t){var e=t.getContext("2d"),i=e.getImageData(0,0,t.width,t.height),r=i.data,s=this.threshold,n=this.distance,o=255-s,a=Math.abs,h,c,l;for(var f=0,u=r.length;f<u;f+=4){h=r[f];c=r[f+1];l=r[f+2];if(h>o&&c>o&&l>o&&a(h-c)<n&&a(h-l)<n&&a(c-l)<n){r[f+3]=0}}e.putImageData(i,0,0)},toObject:function(){return i(this.callSuper("toObject"),{threshold:this.threshold,distance:this.distance})}});e.Image.filters.RemoveWhite.fromObject=function(t){return new e.Image.filters.RemoveWhite(t)}})(typeof exports!=="undefined"?exports:this);(function(t){"use strict";var e=t.fabric||(t.fabric={});e.Image.filters.Sepia=e.util.createClass(e.Image.filters.BaseFilter,{type:"Sepia",applyTo:function(t){var e=t.getContext("2d"),i=e.getImageData(0,0,t.width,t.height),r=i.data,s=r.length,n,o;for(n=0;n<s;n+=4){o=.3*r[n]+.59*r[n+1]+.11*r[n+2];r[n]=o+100;r[n+1]=o+50;r[n+2]=o+255}e.putImageData(i,0,0)}});e.Image.filters.Sepia.fromObject=function(){return new e.Image.filters.Sepia}})(typeof exports!=="undefined"?exports:this);(function(t){"use strict";var e=t.fabric||(t.fabric={});e.Image.filters.Sepia2=e.util.createClass(e.Image.filters.BaseFilter,{type:"Sepia2",applyTo:function(t){var e=t.getContext("2d"),i=e.getImageData(0,0,t.width,t.height),r=i.data,s=r.length,n,o,a,h;for(n=0;n<s;n+=4){o=r[n];a=r[n+1];h=r[n+2];r[n]=(o*.393+a*.769+h*.189)/1.351;r[n+1]=(o*.349+a*.686+h*.168)/1.203;r[n+2]=(o*.272+a*.534+h*.131)/2.14}e.putImageData(i,0,0)}});e.Image.filters.Sepia2.fromObject=function(){return new e.Image.filters.Sepia2}})(typeof exports!=="undefined"?exports:this);(function(t){"use strict";var e=t.fabric||(t.fabric={}),i=e.util.object.extend;e.Image.filters.Tint=e.util.createClass(e.Image.filters.BaseFilter,{type:"Tint",initialize:function(t){t=t||{};this.color=t.color||"#000000";this.opacity=typeof t.opacity!=="undefined"?t.opacity:new e.Color(this.color).getAlpha()},applyTo:function(t){var i=t.getContext("2d"),r=i.getImageData(0,0,t.width,t.height),s=r.data,n=s.length,o,a,h,c,l,f,u,d,g;g=new e.Color(this.color).getSource();a=g[0]*this.opacity;h=g[1]*this.opacity;c=g[2]*this.opacity;d=1-this.opacity;for(o=0;o<n;o+=4){l=s[o];f=s[o+1];u=s[o+2];s[o]=a+l*d;s[o+1]=h+f*d;s[o+2]=c+u*d}i.putImageData(r,0,0)},toObject:function(){return i(this.callSuper("toObject"),{color:this.color,opacity:this.opacity})}});e.Image.filters.Tint.fromObject=function(t){return new e.Image.filters.Tint(t)}})(typeof exports!=="undefined"?exports:this);(function(t){"use strict";var e=t.fabric||(t.fabric={}),i=e.util.object.extend;e.Image.filters.Multiply=e.util.createClass(e.Image.filters.BaseFilter,{type:"Multiply",initialize:function(t){t=t||{};this.color=t.color||"#000000"},applyTo:function(t){var i=t.getContext("2d"),r=i.getImageData(0,0,t.width,t.height),s=r.data,n=s.length,o,a;a=new e.Color(this.color).getSource();for(o=0;o<n;o+=4){s[o]*=a[0]/255;s[o+1]*=a[1]/255;s[o+2]*=a[2]/255}i.putImageData(r,0,0)},toObject:function(){return i(this.callSuper("toObject"),{color:this.color})}});e.Image.filters.Multiply.fromObject=function(t){return new e.Image.filters.Multiply(t)}})(typeof exports!=="undefined"?exports:this);(function(t){"use strict";var e=t.fabric;e.Image.filters.Blend=e.util.createClass(e.Image.filters.BaseFilter,{type:"Blend",initialize:function(t){t=t||{};this.color=t.color||"#000";this.image=t.image||false;this.mode=t.mode||"multiply";this.alpha=t.alpha||1},applyTo:function(t){var i=t.getContext("2d"),r=i.getImageData(0,0,t.width,t.height),s=r.data,n,o,a,h,c,l,f,u,d,g,p=false;if(this.image){p=true;var v=e.util.createCanvasElement();v.width=this.image.width;v.height=this.image.height;var m=new e.StaticCanvas(v);m.add(this.image);var b=m.getContext("2d");g=b.getImageData(0,0,m.width,m.height).data}else{g=new e.Color(this.color).getSource();n=g[0]*this.alpha;o=g[1]*this.alpha;a=g[2]*this.alpha}for(var y=0,_=s.length;y<_;y+=4){h=s[y];c=s[y+1];l=s[y+2];if(p){n=g[y]*this.alpha;o=g[y+1]*this.alpha;a=g[y+2]*this.alpha}switch(this.mode){case"multiply":s[y]=h*n/255;s[y+1]=c*o/255;s[y+2]=l*a/255;break;case"screen":s[y]=1-(1-h)*(1-n);s[y+1]=1-(1-c)*(1-o);s[y+2]=1-(1-l)*(1-a);break;case"add":s[y]=Math.min(255,h+n);s[y+1]=Math.min(255,c+o);s[y+2]=Math.min(255,l+a);break;case"diff":case"difference":s[y]=Math.abs(h-n);s[y+1]=Math.abs(c-o);s[y+2]=Math.abs(l-a);break;case"subtract":f=h-n;u=c-o;d=l-a;s[y]=f<0?0:f;s[y+1]=u<0?0:u;s[y+2]=d<0?0:d;break;case"darken":s[y]=Math.min(h,n);s[y+1]=Math.min(c,o);s[y+2]=Math.min(l,a);break;case"lighten":s[y]=Math.max(h,n);s[y+1]=Math.max(c,o);s[y+2]=Math.max(l,a);break}}i.putImageData(r,0,0)},toObject:function(){return{color:this.color,image:this.image,mode:this.mode,alpha:this.alpha}}});e.Image.filters.Blend.fromObject=function(t){return new e.Image.filters.Blend(t)}})(typeof exports!=="undefined"?exports:this);(function(t){"use strict";var e=t.fabric||(t.fabric={}),i=Math.pow,r=Math.floor,s=Math.sqrt,n=Math.abs,o=Math.max,a=Math.round,h=Math.sin,c=Math.ceil;e.Image.filters.Resize=e.util.createClass(e.Image.filters.BaseFilter,{type:"Resize",resizeType:"hermite",scaleX:0,scaleY:0,lanczosLobes:3,applyTo:function(t,e,i){this.rcpScaleX=1/e;this.rcpScaleY=1/i;var r=t.width,s=t.height,n=a(r*e),o=a(s*i),h;if(this.resizeType==="sliceHack"){h=this.sliceByTwo(t,r,s,n,o)}if(this.resizeType==="hermite"){h=this.hermiteFastResize(t,r,s,n,o)}if(this.resizeType==="bilinear"){h=this.bilinearFiltering(t,r,s,n,o)}if(this.resizeType==="lanczos"){h=this.lanczosResize(t,r,s,n,o)}t.width=n;t.height=o;t.getContext("2d").putImageData(h,0,0)},sliceByTwo:function(t,i,s,n,a){var h=t.getContext("2d"),c,l=.5,f=.5,u=1,d=1,g=false,p=false,v=i,m=s,b=e.util.createCanvasElement(),y=b.getContext("2d");n=r(n);a=r(a);b.width=o(n,i);b.height=o(a,s);if(n>i){l=2;u=-1}if(a>s){f=2;d=-1}c=h.getImageData(0,0,i,s);t.width=o(n,i);t.height=o(a,s);h.putImageData(c,0,0);while(!g||!p){i=v;s=m;if(n*u<r(v*l*u)){v=r(v*l)}else{v=n;g=true}if(a*d<r(m*f*d)){m=r(m*f)}else{m=a;p=true}c=h.getImageData(0,0,i,s);y.putImageData(c,0,0);h.clearRect(0,0,v,m);h.drawImage(b,0,0,i,s,0,0,v,m)}return h.getImageData(0,0,n,a)},lanczosResize:function(t,e,o,a,l){function f(t){return function(e){if(e>t){return 0}e*=Math.PI;if(n(e)<1e-16){return 1}var i=e/t;return h(e)*h(i)/e/i}}function u(t){var h,c,f,d,g,j,A,M,P,L,D;T.x=(t+.5)*y;k.x=r(T.x);for(h=0;h<l;h++){T.y=(h+.5)*_;k.y=r(T.y);g=0,j=0,A=0,M=0,P=0;for(c=k.x-C;c<=k.x+C;c++){if(c<0||c>=e){continue}L=r(1e3*n(c-T.x));if(!O[L]){O[L]={}}for(var E=k.y-w;E<=k.y+w;E++){if(E<0||E>=o){continue}D=r(1e3*n(E-T.y));if(!O[L][D]){O[L][D]=b(s(i(L*x,2)+i(D*S,2))/1e3)}f=O[L][D];if(f>0){d=(E*e+c)*4;g+=f;j+=f*v[d];A+=f*v[d+1];M+=f*v[d+2];P+=f*v[d+3]}}}d=(h*a+t)*4;m[d]=j/g;m[d+1]=A/g;m[d+2]=M/g;m[d+3]=P/g}if(++t<a){return u(t)}else{return p}}var d=t.getContext("2d"),g=d.getImageData(0,0,e,o),p=d.getImageData(0,0,a,l),v=g.data,m=p.data,b=f(this.lanczosLobes),y=this.rcpScaleX,_=this.rcpScaleY,x=2/this.rcpScaleX,S=2/this.rcpScaleY,C=c(y*this.lanczosLobes/2),w=c(_*this.lanczosLobes/2),O={},T={},k={};return u(0)},bilinearFiltering:function(t,e,i,s,n){var o,a,h,c,l,f,u,d,g,p,v,m,b=0,y,_=this.rcpScaleX,x=this.rcpScaleY,S=t.getContext("2d"),C=4*(e-1),w=S.getImageData(0,0,e,i),O=w.data,T=S.getImageData(0,0,s,n),k=T.data;for(u=0;u<n;u++){for(d=0;d<s;d++){l=r(_*d);f=r(x*u);g=_*d-l;p=x*u-f;y=4*(f*e+l);for(v=0;v<4;v++){o=O[y+v];a=O[y+4+v];h=O[y+C+v];c=O[y+C+4+v];m=o*(1-g)*(1-p)+a*g*(1-p)+h*p*(1-g)+c*g*p;k[b++]=m}}}return T},hermiteFastResize:function(t,e,i,o,a){var h=this.rcpScaleX,l=this.rcpScaleY,f=c(h/2),u=c(l/2),d=t.getContext("2d"),g=d.getImageData(0,0,e,i),p=g.data,v=d.getImageData(0,0,o,a),m=v.data;for(var b=0;b<a;b++){for(var y=0;y<o;y++){var _=(y+b*o)*4,x=0,S=0,C=0,w=0,O=0,T=0,k=0,j=(b+.5)*l;for(var A=r(b*l);A<(b+1)*l;A++){var M=n(j-(A+.5))/u,P=(y+.5)*h,L=M*M;for(var D=r(y*h);D<(y+1)*h;D++){var E=n(P-(D+.5))/f,I=s(L+E*E);if(I>1&&I<-1){continue}x=2*I*I*I-3*I*I+1;if(x>0){E=4*(D+A*e);k+=x*p[E+3];C+=x;if(p[E+3]<255){x=x*p[E+3]/250}w+=x*p[E];O+=x*p[E+1];T+=x*p[E+2];S+=x}}}m[_]=w/S;m[_+1]=O/S;m[_+2]=T/S;m[_+3]=k/C}}return v},toObject:function(){return{type:this.type,scaleX:this.scaleX,scaleY:this.scaleY,resizeType:this.resizeType,lanczosLobes:this.lanczosLobes}}});e.Image.filters.Resize.fromObject=function(t){return new e.Image.filters.Resize(t)}})(typeof exports!=="undefined"?exports:this);(function(t){"use strict";var e=t.fabric||(t.fabric={}),i=e.util.object.extend,r=e.util.object.clone,s=e.util.toFixed,n=e.StaticCanvas.supports("setLineDash"),o=e.Object.NUM_FRACTION_DIGITS;if(e.Text){e.warn("fabric.Text is already defined");return}var a=e.Object.prototype.stateProperties.concat();a.push("fontFamily","fontWeight","fontSize","text","textDecoration","textAlign","fontStyle","lineHeight","textBackgroundColor");e.Text=e.util.createClass(e.Object,{_dimensionAffectingProps:{fontSize:true,fontWeight:true,fontFamily:true,fontStyle:true,lineHeight:true,stroke:true,strokeWidth:true,text:true,textAlign:true},_reNewline:/\r?\n/,_reSpacesAndTabs:/[ \t\r]+/g,type:"text",fontSize:40,fontWeight:"normal",fontFamily:"Times New Roman",textDecoration:"",textAlign:"left",fontStyle:"",lineHeight:1.16,textBackgroundColor:"",stateProperties:a,stroke:null,shadow:null,_fontSizeFraction:.25,_fontSizeMult:1.13,initialize:function(t,e){e=e||{};this.text=t;this.__skipDimension=true;this.setOptions(e);this.__skipDimension=false;this._initDimensions()},_initDimensions:function(t){if(this.__skipDimension){return}if(!t){t=e.util.createCanvasElement().getContext("2d");this._setTextStyles(t)}this._textLines=this._splitTextIntoLines();this._clearCache();this.width=this._getTextWidth(t);this.height=this._getTextHeight(t)},toString:function(){return"#<fabric.Text ("+this.complexity()+'): { "text": "'+this.text+'", "fontFamily": "'+this.fontFamily+'" }>'},_render:function(t){this.clipTo&&e.util.clipContext(this,t);this._setOpacity(t);this._setShadow(t);this._setupCompositeOperation(t);this._renderTextBackground(t);this._setStrokeStyles(t);

this._setFillStyles(t);this._renderText(t);this._renderTextDecoration(t);this.clipTo&&t.restore()},_renderText:function(t){this._translateForTextAlign(t);this._renderTextFill(t);this._renderTextStroke(t);this._translateForTextAlign(t,true)},_translateForTextAlign:function(t,e){if(this.textAlign!=="left"&&this.textAlign!=="justify"){var i=e?-1:1;t.translate(this.textAlign==="center"?i*this.width/2:i*this.width,0)}},_setTextStyles:function(t){t.textBaseline="alphabetic";if(!this.skipTextAlign){t.textAlign=this.textAlign}t.font=this._getFontDeclaration()},_getTextHeight:function(){return this._textLines.length*this._getHeightOfLine()},_getTextWidth:function(t){var e=this._getLineWidth(t,0);for(var i=1,r=this._textLines.length;i<r;i++){var s=this._getLineWidth(t,i);if(s>e){e=s}}return e},_renderChars:function(t,e,i,r,s){var n=t.slice(0,-4);if(this[n].toLive){var o=-this.width/2+this[n].offsetX||0,a=-this.height/2+this[n].offsetY||0;e.save();e.translate(o,a);r-=o;s-=a}e[t](i,r,s);this[n].toLive&&e.restore()},_renderTextLine:function(t,e,i,r,s,n){s-=this.fontSize*this._fontSizeFraction;var o=this._getLineWidth(e,n);if(this.textAlign!=="justify"||this.width<o){this._renderChars(t,e,i,r,s,n);return}var a=i.split(/\s+/),h=0,c=this._getWidthOfWords(e,i,n,0),l=this.width-c,f=a.length-1,u=f>0?l/f:0,d=0,g;for(var p=0,v=a.length;p<v;p++){while(i[h]===" "&&h<i.length){h++}g=a[p];this._renderChars(t,e,g,r+d,s,n,h);d+=this._getWidthOfWords(e,g,n,h)+u;h+=g.length}},_getWidthOfWords:function(t,e){return t.measureText(e.replace(/\s+/g,"")).width},_getLeftOffset:function(){return-this.width/2},_getTopOffset:function(){return-this.height/2},isEmptyStyles:function(){return true},_renderTextFill:function(t){if(!this.fill&&this.isEmptyStyles()){return}var e=0;for(var i=0,r=this._textLines.length;i<r;i++){var s=this._getHeightOfLine(t,i),n=s/this.lineHeight;this._renderTextLine("fillText",t,this._textLines[i],this._getLeftOffset(),this._getTopOffset()+e+n,i);e+=s}},_renderTextStroke:function(t){if((!this.stroke||this.strokeWidth===0)&&this.isEmptyStyles()){return}var e=0;if(this.shadow&&!this.shadow.affectStroke){this._removeShadow(t)}t.save();if(this.strokeDashArray){if(1&this.strokeDashArray.length){this.strokeDashArray.push.apply(this.strokeDashArray,this.strokeDashArray)}n&&t.setLineDash(this.strokeDashArray)}t.beginPath();for(var i=0,r=this._textLines.length;i<r;i++){var s=this._getHeightOfLine(t,i),o=s/this.lineHeight;this._renderTextLine("strokeText",t,this._textLines[i],this._getLeftOffset(),this._getTopOffset()+e+o,i);e+=s}t.closePath();t.restore()},_getHeightOfLine:function(){return this.fontSize*this._fontSizeMult*this.lineHeight},_renderTextBackground:function(t){this._renderTextBoxBackground(t);this._renderTextLinesBackground(t)},_renderTextBoxBackground:function(t){if(!this.backgroundColor){return}t.fillStyle=this.backgroundColor;t.fillRect(this._getLeftOffset(),this._getTopOffset(),this.width,this.height);this._removeShadow(t)},_renderTextLinesBackground:function(t){if(!this.textBackgroundColor){return}var e=0,i,r,s;t.fillStyle=this.textBackgroundColor;for(var n=0,o=this._textLines.length;n<o;n++){i=this._getHeightOfLine(t,n);r=this._getLineWidth(t,n);if(r>0){s=this._getLineLeftOffset(r);t.fillRect(this._getLeftOffset()+s,this._getTopOffset()+e,r,i/this.lineHeight)}e+=i}this._removeShadow(t)},_getLineLeftOffset:function(t){if(this.textAlign==="center"){return(this.width-t)/2}if(this.textAlign==="right"){return this.width-t}return 0},_clearCache:function(){this.__lineWidths=[];this.__lineHeights=[]},_shouldClearCache:function(){var t=false;if(this._forceClearCache){this._forceClearCache=false;return true}for(var e in this._dimensionAffectingProps){if(this["__"+e]!==this[e]){this["__"+e]=this[e];t=true}}return t},_getLineWidth:function(t,e){if(this.__lineWidths[e]){return this.__lineWidths[e]===-1?this.width:this.__lineWidths[e]}var i,r,s=this._textLines[e];if(s===""){i=0}else{i=this._measureLine(t,e)}this.__lineWidths[e]=i;if(i&&this.textAlign==="justify"){r=s.split(/\s+/);if(r.length>1){this.__lineWidths[e]=-1}}return i},_measureLine:function(t,e){return t.measureText(this._textLines[e]).width},_renderTextDecoration:function(t){if(!this.textDecoration){return}var e=this.height/2,i=this,r=[];function s(r){var s,n=0,o,a,h,c,l,f;for(s=0,o=i._textLines.length;s<o;s++){c=i._getLineWidth(t,s),l=i._getLineLeftOffset(c),f=i._getHeightOfLine(t,s);for(a=0,h=r.length;a<h;a++){t.fillRect(i._getLeftOffset()+l,n+(i._fontSizeMult-1+r[a])*i.fontSize-e,c,i.fontSize/15)}n+=f}}if(this.textDecoration.indexOf("underline")>-1){r.push(.85)}if(this.textDecoration.indexOf("line-through")>-1){r.push(.43)}if(this.textDecoration.indexOf("overline")>-1){r.push(-.12)}if(r.length>0){s(r)}},_getFontDeclaration:function(){return[e.isLikelyNode?this.fontWeight:this.fontStyle,e.isLikelyNode?this.fontStyle:this.fontWeight,this.fontSize+"px",e.isLikelyNode?'"'+this.fontFamily+'"':this.fontFamily].join(" ")},render:function(t,e){if(!this.visible){return}t.save();this._setTextStyles(t);if(this._shouldClearCache()){this._initDimensions(t)}this.drawSelectionBackground(t);if(!e){this.transform(t)}if(this.transformMatrix){t.transform.apply(t,this.transformMatrix)}if(this.group&&this.group.type==="path-group"){t.translate(this.left,this.top)}this._render(t);t.restore()},_splitTextIntoLines:function(){return this.text.split(this._reNewline)},toObject:function(t){var e=i(this.callSuper("toObject",t),{text:this.text,fontSize:this.fontSize,fontWeight:this.fontWeight,fontFamily:this.fontFamily,fontStyle:this.fontStyle,lineHeight:this.lineHeight,textDecoration:this.textDecoration,textAlign:this.textAlign,textBackgroundColor:this.textBackgroundColor});if(!this.includeDefaultValues){this._removeDefaultValues(e)}return e},toSVG:function(t){var e=this._createBaseSVGMarkup(),i=this._getSVGLeftTopOffsets(this.ctx),r=this._getSVGTextAndBg(i.textTop,i.textLeft);this._wrapSVGTextAndBg(e,r);return t?t(e.join("")):e.join("")},_getSVGLeftTopOffsets:function(t){var e=this._getHeightOfLine(t,0),i=-this.width/2,r=0;return{textLeft:i+(this.group&&this.group.type==="path-group"?this.left:0),textTop:r+(this.group&&this.group.type==="path-group"?-this.top:0),lineTop:e}},_wrapSVGTextAndBg:function(t,e){var i=true,r=this.getSvgFilter(),s=r===""?"":' style="'+r+'"';t.push('	<g transform="',this.getSvgTransform(),this.getSvgTransformMatrix(),'"',s,">\n",e.textBgRects.join(""),"		<text ",this.fontFamily?'font-family="'+this.fontFamily.replace(/"/g,"'")+'" ':"",this.fontSize?'font-size="'+this.fontSize+'" ':"",this.fontStyle?'font-style="'+this.fontStyle+'" ':"",this.fontWeight?'font-weight="'+this.fontWeight+'" ':"",this.textDecoration?'text-decoration="'+this.textDecoration+'" ':"",'style="',this.getSvgStyles(i),'" >\n',e.textSpans.join(""),"		</text>\n","	</g>\n")},_getSVGTextAndBg:function(t,e){var i=[],r=[],s=0;this._setSVGBg(r);for(var n=0,o=this._textLines.length;n<o;n++){if(this.textBackgroundColor){this._setSVGTextLineBg(r,n,e,t,s)}this._setSVGTextLineText(n,i,s,e,t,r);s+=this._getHeightOfLine(this.ctx,n)}return{textSpans:i,textBgRects:r}},_setSVGTextLineText:function(t,i,r,n,a){var h=this.fontSize*(this._fontSizeMult-this._fontSizeFraction)-a+r-this.height/2;if(this.textAlign==="justify"){this._setSVGTextLineJustifed(t,i,h,n);return}i.push('			<tspan x="',s(n+this._getLineLeftOffset(this._getLineWidth(this.ctx,t)),o),'" ','y="',s(h,o),'" ',this._getFillAttributes(this.fill),">",e.util.string.escapeXml(this._textLines[t]),"</tspan>\n")},_setSVGTextLineJustifed:function(t,i,r,n){var a=e.util.createCanvasElement().getContext("2d");this._setTextStyles(a);var h=this._textLines[t],c=h.split(/\s+/),l=this._getWidthOfWords(a,h),f=this.width-l,u=c.length-1,d=u>0?f/u:0,g,p=this._getFillAttributes(this.fill),v;n+=this._getLineLeftOffset(this._getLineWidth(a,t));for(t=0,v=c.length;t<v;t++){g=c[t];i.push('			<tspan x="',s(n,o),'" ','y="',s(r,o),'" ',p,">",e.util.string.escapeXml(g),"</tspan>\n");n+=this._getWidthOfWords(a,g)+d}},_setSVGTextLineBg:function(t,e,i,r,n){t.push("		<rect ",this._getFillAttributes(this.textBackgroundColor),' x="',s(i+this._getLineLeftOffset(this._getLineWidth(this.ctx,e)),o),'" y="',s(n-this.height/2,o),'" width="',s(this._getLineWidth(this.ctx,e),o),'" height="',s(this._getHeightOfLine(this.ctx,e)/this.lineHeight,o),'"></rect>\n')},_setSVGBg:function(t){if(this.backgroundColor){t.push("		<rect ",this._getFillAttributes(this.backgroundColor),' x="',s(-this.width/2,o),'" y="',s(-this.height/2,o),'" width="',s(this.width,o),'" height="',s(this.height,o),'"></rect>\n')}},_getFillAttributes:function(t){var i=t&&typeof t==="string"?new e.Color(t):"";if(!i||!i.getSource()||i.getAlpha()===1){return'fill="'+t+'"'}return'opacity="'+i.getAlpha()+'" fill="'+i.setAlpha(1).toRgb()+'"'},_set:function(t,e){this.callSuper("_set",t,e);if(t in this._dimensionAffectingProps){this._initDimensions();this.setCoords()}},complexity:function(){return 1}});e.Text.ATTRIBUTE_NAMES=e.SHARED_ATTRIBUTES.concat("x y dx dy font-family font-style font-weight font-size text-decoration text-anchor".split(" "));e.Text.DEFAULT_SVG_FONT_SIZE=16;e.Text.fromElement=function(t,i){if(!t){return null}var r=e.parseAttributes(t,e.Text.ATTRIBUTE_NAMES);i=e.util.object.extend(i?e.util.object.clone(i):{},r);i.top=i.top||0;i.left=i.left||0;if("dx"in r){i.left+=r.dx}if("dy"in r){i.top+=r.dy}if(!("fontSize"in i)){i.fontSize=e.Text.DEFAULT_SVG_FONT_SIZE}if(!i.originX){i.originX="left"}var s="";if(!("textContent"in t)){if("firstChild"in t&&t.firstChild!==null){if("data"in t.firstChild&&t.firstChild.data!==null){s=t.firstChild.data}}}else{s=t.textContent}s=s.replace(/^\s+|\s+$|\n+/g,"").replace(/\s+/g," ");var n=new e.Text(s,i),o=0;if(n.originX==="left"){o=n.getWidth()/2}if(n.originX==="right"){o=-n.getWidth()/2}n.set({left:n.getLeft()+o,top:n.getTop()-n.getHeight()/2+n.fontSize*(.18+n._fontSizeFraction)});return n};e.Text.fromObject=function(t){return new e.Text(t.text,r(t))};e.util.createAccessors(e.Text)})(typeof exports!=="undefined"?exports:this);(function(){var t=fabric.util.object.clone;fabric.IText=fabric.util.createClass(fabric.Text,fabric.Observable,{type:"i-text",selectionStart:0,selectionEnd:0,selectionColor:"rgba(17,119,255,0.3)",isEditing:false,editable:true,editingBorderColor:"rgba(102,153,255,0.25)",cursorWidth:2,cursorColor:"#333",cursorDelay:1e3,cursorDuration:600,styles:null,caching:true,_reSpace:/\s|\n/,_currentCursorOpacity:0,_selectionDirection:null,_abortCursorAnimation:false,_charWidthsCache:{},__widthOfSpace:[],initialize:function(t,e){this.styles=e?e.styles||{}:{};this.callSuper("initialize",t,e);this.initBehavior()},_clearCache:function(){this.callSuper("_clearCache");this.__widthOfSpace=[]},isEmptyStyles:function(){if(!this.styles){return true}var t=this.styles;for(var e in t){for(var i in t[e]){for(var r in t[e][i]){return false}}}return true},setSelectionStart:function(t){t=Math.max(t,0);if(this.selectionStart!==t){this.fire("selection:changed");this.canvas&&this.canvas.fire("text:selection:changed",{target:this});this.selectionStart=t}this._updateTextarea()},setSelectionEnd:function(t){t=Math.min(t,this.text.length);if(this.selectionEnd!==t){this.fire("selection:changed");this.canvas&&this.canvas.fire("text:selection:changed",{target:this});this.selectionEnd=t}this._updateTextarea()},getSelectionStyles:function(t,e){if(arguments.length===2){var i=[];for(var r=t;r<e;r++){i.push(this.getSelectionStyles(r))}return i}var s=this.get2DCursorLocation(t),n=this._getStyleDeclaration(s.lineIndex,s.charIndex);return n||{}},setSelectionStyles:function(t){if(this.selectionStart===this.selectionEnd){this._extendStyles(this.selectionStart,t)}else{for(var e=this.selectionStart;e<this.selectionEnd;e++){this._extendStyles(e,t)}}this._forceClearCache=true;return this},_extendStyles:function(t,e){var i=this.get2DCursorLocation(t);if(!this._getLineStyle(i.lineIndex)){this._setLineStyle(i.lineIndex,{})}if(!this._getStyleDeclaration(i.lineIndex,i.charIndex)){this._setStyleDeclaration(i.lineIndex,i.charIndex,{})}fabric.util.object.extend(this._getStyleDeclaration(i.lineIndex,i.charIndex),e)},_render:function(t){this.callSuper("_render",t);this.ctx=t;this.isEditing&&this.renderCursorOrSelection()},renderCursorOrSelection:function(){if(!this.active){return}var t=this.text.split(""),e,i;if(this.canvas.contextTop){i=this.canvas.contextTop;i.save();i.transform.apply(i,this.canvas.viewportTransform);this.transform(i);this.transformMatrix&&i.transform.apply(i,this.transformMatrix)}else{i=this.ctx;i.save()}if(this.selectionStart===this.selectionEnd){e=this._getCursorBoundaries(t,"cursor");this.renderCursor(e,i)}else{e=this._getCursorBoundaries(t,"selection");this.renderSelection(t,e,i)}i.restore()},get2DCursorLocation:function(t){if(typeof t==="undefined"){t=this.selectionStart}var e=this._textLines.length;for(var i=0;i<e;i++){if(t<=this._textLines[i].length){return{lineIndex:i,charIndex:t}}t-=this._textLines[i].length+1}return{lineIndex:i-1,charIndex:this._textLines[i-1].length<t?this._textLines[i-1].length:t}},getCurrentCharStyle:function(t,e){var i=this._getStyleDeclaration(t,e===0?0:e-1);return{fontSize:i&&i.fontSize||this.fontSize,fill:i&&i.fill||this.fill,textBackgroundColor:i&&i.textBackgroundColor||this.textBackgroundColor,textDecoration:i&&i.textDecoration||this.textDecoration,fontFamily:i&&i.fontFamily||this.fontFamily,fontWeight:i&&i.fontWeight||this.fontWeight,fontStyle:i&&i.fontStyle||this.fontStyle,stroke:i&&i.stroke||this.stroke,strokeWidth:i&&i.strokeWidth||this.strokeWidth}},getCurrentCharFontSize:function(t,e){var i=this._getStyleDeclaration(t,e===0?0:e-1);return i&&i.fontSize?i.fontSize:this.fontSize},getCurrentCharColor:function(t,e){var i=this._getStyleDeclaration(t,e===0?0:e-1);return i&&i.fill?i.fill:this.cursorColor},_getCursorBoundaries:function(t,e){var i=Math.round(this._getLeftOffset()),r=this._getTopOffset(),s=this._getCursorBoundariesOffsets(t,e);return{left:i,top:r,leftOffset:s.left+s.lineLeft,topOffset:s.top}},_getCursorBoundariesOffsets:function(t,e){var i=0,r=0,s=0,n=0,o=0;for(var a=0;a<this.selectionStart;a++){if(t[a]==="\n"){o=0;n+=this._getHeightOfLine(this.ctx,r);r++;s=0}else{o+=this._getWidthOfChar(this.ctx,t[a],r,s);s++}i=this._getLineLeftOffset(this._getLineWidth(this.ctx,r))}if(e==="cursor"){n+=(1-this._fontSizeFraction)*this._getHeightOfLine(this.ctx,r)/this.lineHeight-this.getCurrentCharFontSize(r,s)*(1-this._fontSizeFraction)}return{top:n,left:o,lineLeft:i}},renderCursor:function(t,e){var i=this.get2DCursorLocation(),r=i.lineIndex,s=i.charIndex,n=this.getCurrentCharFontSize(r,s),o=r===0&&s===0?this._getLineLeftOffset(this._getLineWidth(e,r)):t.leftOffset;e.fillStyle=this.getCurrentCharColor(r,s);e.globalAlpha=this.__isMousedown?1:this._currentCursorOpacity;e.fillRect(t.left+o,t.top+t.topOffset,this.cursorWidth/this.scaleX,n)},renderSelection:function(t,e,i){i.fillStyle=this.selectionColor;var r=this.get2DCursorLocation(this.selectionStart),s=this.get2DCursorLocation(this.selectionEnd),n=r.lineIndex,o=s.lineIndex;for(var a=n;a<=o;a++){var h=this._getLineLeftOffset(this._getLineWidth(i,a))||0,c=this._getHeightOfLine(this.ctx,a),l=0,f=this._textLines[a];if(a===n){for(var u=0,d=f.length;u<d;u++){if(u>=r.charIndex&&(a!==o||u<s.charIndex)){l+=this._getWidthOfChar(i,f[u],a,u)}if(u<r.charIndex){h+=this._getWidthOfChar(i,f[u],a,u)}}}else if(a>n&&a<o){l+=this._getLineWidth(i,a)||5}else if(a===o){for(var g=0,p=s.charIndex;g<p;g++){l+=this._getWidthOfChar(i,f[g],a,g)}}i.fillRect(e.left+h,e.top+e.topOffset,l,c);e.topOffset+=c}},_renderChars:function(t,e,i,r,s,n,o){if(this.isEmptyStyles()){return this._renderCharsFast(t,e,i,r,s)}o=o||0;this.skipTextAlign=true;r-=this.textAlign==="center"?this.width/2:this.textAlign==="right"?this.width:0;var a=this._getHeightOfLine(e,n),h=this._getLineLeftOffset(this._getLineWidth(e,n)),c,l,f="";r+=h||0;e.save();s-=a/this.lineHeight*this._fontSizeFraction;for(var u=o,d=i.length+o;u<=d;u++){c=c||this.getCurrentCharStyle(n,u);l=this.getCurrentCharStyle(n,u+1);if(this._hasStyleChanged(c,l)||u===d){this._renderChar(t,e,n,u-1,f,r,s,a);f="";c=l}f+=i[u-o]}e.restore()},_renderCharsFast:function(t,e,i,r,s){this.skipTextAlign=false;if(t==="fillText"&&this.fill){this.callSuper("_renderChars",t,e,i,r,s)}if(t==="strokeText"&&(this.stroke&&this.strokeWidth>0||this.skipFillStrokeCheck)){this.callSuper("_renderChars",t,e,i,r,s)}},_renderChar:function(t,e,i,r,s,n,o,a){var h,c,l,f,u=this._getStyleDeclaration(i,r),d,g;if(u){c=this._getHeightOfChar(e,s,i,r);f=u.stroke;l=u.fill;g=u.textDecoration}else{c=this.fontSize}f=(f||this.stroke)&&t==="strokeText";l=(l||this.fill)&&t==="fillText";u&&e.save();h=this._applyCharStylesGetWidth(e,s,i,r,u||{});g=g||this.textDecoration;if(u&&u.textBackgroundColor){this._removeShadow(e)}l&&e.fillText(s,n,o);f&&e.strokeText(s,n,o);if(g||g!==""){d=this._fontSizeFraction*a/this.lineHeight;this._renderCharDecoration(e,g,n,o,d,h,c)}u&&e.restore();e.translate(h,0)},_hasStyleChanged:function(t,e){return t.fill!==e.fill||t.fontSize!==e.fontSize||t.textBackgroundColor!==e.textBackgroundColor||t.textDecoration!==e.textDecoration||t.fontFamily!==e.fontFamily||t.fontWeight!==e.fontWeight||t.fontStyle!==e.fontStyle||t.stroke!==e.stroke||t.strokeWidth!==e.strokeWidth},_renderCharDecoration:function(t,e,i,r,s,n,o){if(!e){return}var a=o/15,h={underline:r+o/10,"line-through":r-o*(this._fontSizeFraction+this._fontSizeMult-1)+a,overline:r-(this._fontSizeMult-this._fontSizeFraction)*o},c=["underline","line-through","overline"],l,f;for(l=0;l<c.length;l++){f=c[l];if(e.indexOf(f)>-1){t.fillRect(i,h[f],n,a)}}},_renderTextLine:function(t,e,i,r,s,n){if(!this.isEmptyStyles()){s+=this.fontSize*(this._fontSizeFraction+.03)}this.callSuper("_renderTextLine",t,e,i,r,s,n)},_renderTextDecoration:function(t){if(this.isEmptyStyles()){return this.callSuper("_renderTextDecoration",t)}},_renderTextLinesBackground:function(t){this.callSuper("_renderTextLinesBackground",t);var e=0,i,r,s,n=this._getLeftOffset(),o=this._getTopOffset(),a,h,c;for(var l=0,f=this._textLines.length;l<f;l++){i=this._getHeightOfLine(t,l);a=this._textLines[l];if(a===""||!this.styles||!this._getLineStyle(l)){e+=i;continue}r=this._getLineWidth(t,l);s=this._getLineLeftOffset(r);for(var u=0,d=a.length;u<d;u++){c=this._getStyleDeclaration(l,u);if(!c||!c.textBackgroundColor){continue}h=a[u];t.fillStyle=c.textBackgroundColor;t.fillRect(n+s+this._getWidthOfCharsAt(t,l,u),o+e,this._getWidthOfChar(t,h,l,u)+1,i/this.lineHeight)}e+=i}},_getCacheProp:function(t,e){return t+e.fontFamily+e.fontSize+e.fontWeight+e.fontStyle+e.shadow},_applyCharStylesGetWidth:function(e,i,r,s,n){var o=this._getStyleDeclaration(r,s),a=n&&t(n)||t(o),h;this._applyFontStyles(a);var c=this._getCacheProp(i,a);if(!o&&this._charWidthsCache[c]&&this.caching){return this._charWidthsCache[c]}if(typeof a.shadow==="string"){a.shadow=new fabric.Shadow(a.shadow)}var l=a.fill||this.fill;e.fillStyle=l.toLive?l.toLive(e,this):l;if(a.stroke){e.strokeStyle=a.stroke&&a.stroke.toLive?a.stroke.toLive(e,this):a.stroke}e.lineWidth=a.strokeWidth||this.strokeWidth;e.font=this._getFontDeclaration.call(a);if(a.shadow){a.scaleX=this.scaleX;a.scaleY=this.scaleY;a.canvas=this.canvas;this._setShadow.call(a,e)}if(!this.caching||!this._charWidthsCache[c]){h=e.measureText(i).width;this.caching&&(this._charWidthsCache[c]=h);return h}return this._charWidthsCache[c]},_applyFontStyles:function(t){if(!t.fontFamily){t.fontFamily=this.fontFamily}if(!t.fontSize){t.fontSize=this.fontSize}if(!t.fontWeight){t.fontWeight=this.fontWeight}if(!t.fontStyle){t.fontStyle=this.fontStyle}},_getStyleDeclaration:function(e,i,r){if(r){return this.styles[e]&&this.styles[e][i]?t(this.styles[e][i]):{}}return this.styles[e]&&this.styles[e][i]?this.styles[e][i]:null},_setStyleDeclaration:function(t,e,i){this.styles[t][e]=i},_deleteStyleDeclaration:function(t,e){delete this.styles[t][e]},_getLineStyle:function(t){return this.styles[t]},_setLineStyle:function(t,e){this.styles[t]=e},_deleteLineStyle:function(t){delete this.styles[t]},_getWidthOfChar:function(t,e,i,r){if(!this._isMeasuring&&this.textAlign==="justify"&&this._reSpacesAndTabs.test(e)){return this._getWidthOfSpace(t,i)}var s=this._getStyleDeclaration(i,r,true);this._applyFontStyles(s);var n=this._getCacheProp(e,s);if(this._charWidthsCache[n]&&this.caching){return this._charWidthsCache[n]}else if(t){t.save();var o=this._applyCharStylesGetWidth(t,e,i,r);t.restore();return o}},_getHeightOfChar:function(t,e,i){var r=this._getStyleDeclaration(e,i);return r&&r.fontSize?r.fontSize:this.fontSize},_getWidthOfCharsAt:function(t,e,i){var r=0,s,n;for(s=0;s<i;s++){n=this._textLines[e][s];r+=this._getWidthOfChar(t,n,e,s)}return r},_measureLine:function(t,e){this._isMeasuring=true;var i=this._getWidthOfCharsAt(t,e,this._textLines[e].length);this._isMeasuring=false;return i},_getWidthOfSpace:function(t,e){if(this.__widthOfSpace[e]){return this.__widthOfSpace[e]}var i=this._textLines[e],r=this._getWidthOfWords(t,i,e,0),s=this.width-r,n=i.length-i.replace(this._reSpacesAndTabs,"").length,o=Math.max(s/n,t.measureText(" ").width);this.__widthOfSpace[e]=o;return o},_getWidthOfWords:function(t,e,i,r){var s=0;for(var n=0;n<e.length;n++){var o=e[n];if(!o.match(/\s/)){s+=this._getWidthOfChar(t,o,i,n+r)}}return s},_getHeightOfLine:function(t,e){if(this.__lineHeights[e]){return this.__lineHeights[e]}var i=this._textLines[e],r=this._getHeightOfChar(t,e,0);for(var s=1,n=i.length;s<n;s++){var o=this._getHeightOfChar(t,e,s);if(o>r){r=o}}this.__lineHeights[e]=r*this.lineHeight*this._fontSizeMult;return this.__lineHeights[e]},_getTextHeight:function(t){var e=0;for(var i=0,r=this._textLines.length;i<r;i++){e+=this._getHeightOfLine(t,i)}return e},toObject:function(e){var i={},r,s,n;for(r in this.styles){n=this.styles[r];i[r]={};for(s in n){i[r][s]=t(n[s])}}return fabric.util.object.extend(this.callSuper("toObject",e),{styles:i})}});fabric.IText.fromObject=function(e){return new fabric.IText(e.text,t(e))}})();(function(){var t=fabric.util.object.clone;fabric.util.object.extend(fabric.IText.prototype,{initBehavior:function(){this.initAddedHandler();this.initRemovedHandler();this.initCursorSelectionHandlers();this.initDoubleClickSimulation()},initSelectedHandler:function(){this.on("selected",function(){var t=this;setTimeout(function(){t.selected=true},100)})},initAddedHandler:function(){var t=this;this.on("added",function(){if(this.canvas&&!this.canvas._hasITextHandlers){this.canvas._hasITextHandlers=true;this._initCanvasHandlers()}if(t.canvas){t.canvas._iTextInstances=t.canvas._iTextInstances||[];t.canvas._iTextInstances.push(t)}})},initRemovedHandler:function(){var t=this;this.on("removed",function(){if(t.canvas){t.canvas._iTextInstances=t.canvas._iTextInstances||[];fabric.util.removeFromArray(t.canvas._iTextInstances,t)}})},_initCanvasHandlers:function(){var t=this;this.canvas.on("selection:cleared",function(){fabric.IText.prototype.exitEditingOnOthers(t.canvas)});this.canvas.on("mouse:up",function(){if(t.canvas._iTextInstances){t.canvas._iTextInstances.forEach(function(t){t.__isMousedown=false})}});this.canvas.on("object:selected",function(){fabric.IText.prototype.exitEditingOnOthers(t.canvas)})},_tick:function(){this._currentTickState=this._animateCursor(this,1,this.cursorDuration,"_onTickComplete")},_animateCursor:function(t,e,i,r){var s;s={isAborted:false,abort:function(){this.isAborted=true}};t.animate("_currentCursorOpacity",e,{duration:i,onComplete:function(){if(!s.isAborted){t[r]()}},onChange:function(){if(t.canvas){t.canvas.clearContext(t.canvas.contextTop||t.ctx);t.renderCursorOrSelection()}},abort:function(){return s.isAborted}});return s},_onTickComplete:function(){var t=this;if(this._cursorTimeout1){clearTimeout(this._cursorTimeout1)}this._cursorTimeout1=setTimeout(function(){t._currentTickCompleteState=t._animateCursor(t,0,this.cursorDuration/2,"_tick")},100)},initDelayedCursor:function(t){var e=this,i=t?0:this.cursorDelay;this._currentTickState&&this._currentTickState.abort();this._currentTickCompleteState&&this._currentTickCompleteState.abort();clearTimeout(this._cursorTimeout1);this._currentCursorOpacity=1;if(this.canvas){this.canvas.clearContext(this.canvas.contextTop||this.ctx);this.renderCursorOrSelection()}if(this._cursorTimeout2){clearTimeout(this._cursorTimeout2)}this._cursorTimeout2=setTimeout(function(){e._tick()},i)},abortCursorAnimation:function(){this._currentTickState&&this._currentTickState.abort();this._currentTickCompleteState&&this._currentTickCompleteState.abort();clearTimeout(this._cursorTimeout1);clearTimeout(this._cursorTimeout2);this._currentCursorOpacity=0;this.canvas&&this.canvas.clearContext(this.canvas.contextTop||this.ctx)},selectAll:function(){this.setSelectionStart(0);this.setSelectionEnd(this.text.length)},getSelectedText:function(){return this.text.slice(this.selectionStart,this.selectionEnd)},findWordBoundaryLeft:function(t){var e=0,i=t-1;if(this._reSpace.test(this.text.charAt(i))){while(this._reSpace.test(this.text.charAt(i))){e++;i--}}while(/\S/.test(this.text.charAt(i))&&i>-1){e++;i--}return t-e},findWordBoundaryRight:function(t){var e=0,i=t;if(this._reSpace.test(this.text.charAt(i))){while(this._reSpace.test(this.text.charAt(i))){e++;i++}}while(/\S/.test(this.text.charAt(i))&&i<this.text.length){e++;i++}return t+e},findLineBoundaryLeft:function(t){var e=0,i=t-1;while(!/\n/.test(this.text.charAt(i))&&i>-1){e++;i--}return t-e},findLineBoundaryRight:function(t){var e=0,i=t;while(!/\n/.test(this.text.charAt(i))&&i<this.text.length){e++;i++}return t+e},getNumNewLinesInSelectedText:function(){var t=this.getSelectedText(),e=0;for(var i=0,r=t.length;i<r;i++){if(t[i]==="\n"){e++}}return e},searchWordBoundary:function(t,e){var i=this._reSpace.test(this.text.charAt(t))?t-1:t,r=this.text.charAt(i),s=/[ \n\.,;!\?\-]/;while(!s.test(r)&&i>0&&i<this.text.length){i+=e;r=this.text.charAt(i)}if(s.test(r)&&r!=="\n"){i+=e===1?0:1}return i},selectWord:function(t){var e=this.searchWordBoundary(t,-1),i=this.searchWordBoundary(t,1);this.setSelectionStart(e);this.setSelectionEnd(i)},selectLine:function(t){var e=this.findLineBoundaryLeft(t),i=this.findLineBoundaryRight(t);this.setSelectionStart(e);this.setSelectionEnd(i)},enterEditing:function(t){if(this.isEditing||!this.editable){return}if(this.canvas){this.exitEditingOnOthers(this.canvas)}this.isEditing=true;this.initHiddenTextarea(t);this.hiddenTextarea.focus();this._updateTextarea();this._saveEditingProps();this._setEditingProps();this._textBeforeEdit=this.text;this._tick();this.fire("editing:entered");if(!this.canvas){return this}this.canvas.renderAll();this.canvas.fire("text:editing:entered",{target:this});this.initMouseMoveHandler();return this},exitEditingOnOthers:function(t){if(t._iTextInstances){t._iTextInstances.forEach(function(t){t.selected=false;if(t.isEditing){t.exitEditing()}})}},initMouseMoveHandler:function(){var t=this;this.canvas.on("mouse:move",function(e){if(!t.__isMousedown||!t.isEditing){return}var i=t.getSelectionStartFromPointer(e.e);if(i>=t.__selectionStartOnMouseDown){t.setSelectionStart(t.__selectionStartOnMouseDown);t.setSelectionEnd(i)}else{t.setSelectionStart(i);t.setSelectionEnd(t.__selectionStartOnMouseDown)}})},_setEditingProps:function(){this.hoverCursor="text";if(this.canvas){this.canvas.defaultCursor=this.canvas.moveCursor="text"}this.borderColor=this.editingBorderColor;this.hasControls=this.selectable=false;this.lockMovementX=this.lockMovementY=true},_updateTextarea:function(){if(!this.hiddenTextarea||this.inCompositionMode){return}this.hiddenTextarea.value=this.text;this.hiddenTextarea.selectionStart=this.selectionStart;this.hiddenTextarea.selectionEnd=this.selectionEnd;if(this.selectionStart===this.selectionEnd){var t=this._calcTextareaPosition();this.hiddenTextarea.style.left=t.x+"px";this.hiddenTextarea.style.top=t.y+"px"}},_calcTextareaPosition:function(){var t=this.text.split(""),e=this._getCursorBoundaries(t,"cursor"),i=this.get2DCursorLocation(),r=i.lineIndex,s=i.charIndex,n=this.getCurrentCharFontSize(r,s),o=r===0&&s===0?this._getLineLeftOffset(this._getLineWidth(this.ctx,r)):e.leftOffset,a=this.calcTransformMatrix(),h={x:e.left+o,y:e.top+e.topOffset+n};this.hiddenTextarea.style.fontSize=n+"px";return fabric.util.transformPoint(h,a)},_saveEditingProps:function(){this._savedProps={hasControls:this.hasControls,borderColor:this.borderColor,lockMovementX:this.lockMovementX,lockMovementY:this.lockMovementY,hoverCursor:this.hoverCursor,defaultCursor:this.canvas&&this.canvas.defaultCursor,moveCursor:this.canvas&&this.canvas.moveCursor}},_restoreEditingProps:function(){if(!this._savedProps){return}this.hoverCursor=this._savedProps.overCursor;this.hasControls=this._savedProps.hasControls;this.borderColor=this._savedProps.borderColor;this.lockMovementX=this._savedProps.lockMovementX;this.lockMovementY=this._savedProps.lockMovementY;if(this.canvas){this.canvas.defaultCursor=this._savedProps.defaultCursor;this.canvas.moveCursor=this._savedProps.moveCursor}},exitEditing:function(){var t=this._textBeforeEdit!==this.text;this.selected=false;this.isEditing=false;this.selectable=true;this.selectionEnd=this.selectionStart;this.hiddenTextarea&&this.canvas&&this.hiddenTextarea.parentNode.removeChild(this.hiddenTextarea);this.hiddenTextarea=null;this.abortCursorAnimation();this._restoreEditingProps();this._currentCursorOpacity=0;this.fire("editing:exited");t&&this.fire("modified");if(this.canvas){this.canvas.fire("text:editing:exited",{target:this});t&&this.canvas.fire("object:modified",{target:this})}return this},_removeExtraneousStyles:function(){for(var t in this.styles){if(!this._textLines[t]){delete this.styles[t]}}},_removeCharsFromTo:function(t,e){while(e!==t){this._removeSingleCharAndStyle(t+1);e--}this.setSelectionStart(t)},_removeSingleCharAndStyle:function(t){var e=this.text[t-1]==="\n",i=e?t:t-1;this.removeStyleObject(e,i);this.text=this.text.slice(0,t-1)+this.text.slice(t);this._textLines=this._splitTextIntoLines()},insertChars:function(t,e){var i;if(this.selectionEnd-this.selectionStart>1){this._removeCharsFromTo(this.selectionStart,this.selectionEnd);this.setSelectionEnd(this.selectionStart)}if(!e&&this.isEmptyStyles()){this.insertChar(t,false);return}for(var r=0,s=t.length;r<s;r++){if(e){i=fabric.copiedTextStyle[r]}this.insertChar(t[r],r<s-1,i)}},insertChar:function(t,e,i){var r=this.text[this.selectionStart]==="\n";this.text=this.text.slice(0,this.selectionStart)+t+this.text.slice(this.selectionEnd);this._textLines=this._splitTextIntoLines();this.insertStyleObjects(t,r,i);this.selectionStart+=t.length;this.selectionEnd=this.selectionStart;if(e){return}this._updateTextarea();this.canvas&&this.canvas.renderAll();this.setCoords();this.fire("changed");this.canvas&&this.canvas.fire("text:changed",{target:this})},insertNewlineStyleObject:function(e,i,r){this.shiftLineStyles(e,+1);if(!this.styles[e+1]){this.styles[e+1]={}}var s={},n={};if(this.styles[e]&&this.styles[e][i-1]){s=this.styles[e][i-1]}if(r){n[0]=t(s);this.styles[e+1]=n}else{for(var o in this.styles[e]){if(parseInt(o,10)>=i){n[parseInt(o,10)-i]=this.styles[e][o];delete this.styles[e][o]}}this.styles[e+1]=n}this._forceClearCache=true},insertCharStyleObject:function(e,i,r){var s=this.styles[e],n=t(s);if(i===0&&!r){i=1}for(var o in n){var a=parseInt(o,10);if(a>=i){s[a+1]=n[a];if(!n[a-1]){delete s[a]}}}this.styles[e][i]=r||t(s[i-1]);this._forceClearCache=true},insertStyleObjects:function(t,e,i){var r=this.get2DCursorLocation(),s=r.lineIndex,n=r.charIndex;if(!this._getLineStyle(s)){this._setLineStyle(s,{})}if(t==="\n"){this.insertNewlineStyleObject(s,n,e)}else{this.insertCharStyleObject(s,n,i)}},shiftLineStyles:function(e,i){var r=t(this.styles);for(var s in this.styles){var n=parseInt(s,10);if(n>e){this.styles[n+i]=r[n];if(!r[n-i]){delete this.styles[n]}}}},removeStyleObject:function(t,e){var i=this.get2DCursorLocation(e),r=i.lineIndex,s=i.charIndex;this._removeStyleObject(t,i,r,s)},_getTextOnPreviousLine:function(t){return this._textLines[t-1]},_removeStyleObject:function(e,i,r,s){if(e){var n=this._getTextOnPreviousLine(i.lineIndex),o=n?n.length:0;

if(!this.styles[r-1]){this.styles[r-1]={}}for(s in this.styles[r]){this.styles[r-1][parseInt(s,10)+o]=this.styles[r][s]}this.shiftLineStyles(i.lineIndex,-1)}else{var a=this.styles[r];if(a){delete a[s]}var h=t(a);for(var c in h){var l=parseInt(c,10);if(l>=s&&l!==0){a[l-1]=h[l];delete a[l]}}}},insertNewline:function(){this.insertChars("\n")}})})();fabric.util.object.extend(fabric.IText.prototype,{initDoubleClickSimulation:function(){this.__lastClickTime=+new Date;this.__lastLastClickTime=+new Date;this.__lastPointer={};this.on("mousedown",this.onMouseDown.bind(this))},onMouseDown:function(t){this.__newClickTime=+new Date;var e=this.canvas.getPointer(t.e);if(this.isTripleClick(e)){this.fire("tripleclick",t);this._stopEvent(t.e)}else if(this.isDoubleClick(e)){this.fire("dblclick",t);this._stopEvent(t.e)}this.__lastLastClickTime=this.__lastClickTime;this.__lastClickTime=this.__newClickTime;this.__lastPointer=e;this.__lastIsEditing=this.isEditing;this.__lastSelected=this.selected},isDoubleClick:function(t){return this.__newClickTime-this.__lastClickTime<500&&this.__lastPointer.x===t.x&&this.__lastPointer.y===t.y&&this.__lastIsEditing},isTripleClick:function(t){return this.__newClickTime-this.__lastClickTime<500&&this.__lastClickTime-this.__lastLastClickTime<500&&this.__lastPointer.x===t.x&&this.__lastPointer.y===t.y},_stopEvent:function(t){t.preventDefault&&t.preventDefault();t.stopPropagation&&t.stopPropagation()},initCursorSelectionHandlers:function(){this.initSelectedHandler();this.initMousedownHandler();this.initMouseupHandler();this.initClicks()},initClicks:function(){this.on("dblclick",function(t){this.selectWord(this.getSelectionStartFromPointer(t.e))});this.on("tripleclick",function(t){this.selectLine(this.getSelectionStartFromPointer(t.e))})},initMousedownHandler:function(){this.on("mousedown",function(t){if(!this.editable){return}var e=this.canvas.getPointer(t.e);this.__mousedownX=e.x;this.__mousedownY=e.y;this.__isMousedown=true;if(this.hiddenTextarea&&this.canvas){this.canvas.wrapperEl.appendChild(this.hiddenTextarea)}if(this.selected){this.setCursorByClick(t.e)}if(this.isEditing){this.__selectionStartOnMouseDown=this.selectionStart;this.initDelayedCursor(true)}})},_isObjectMoved:function(t){var e=this.canvas.getPointer(t);return this.__mousedownX!==e.x||this.__mousedownY!==e.y},initMouseupHandler:function(){this.on("mouseup",function(t){this.__isMousedown=false;if(!this.editable||this._isObjectMoved(t.e)){return}if(this.__lastSelected&&!this.__corner){this.enterEditing(t.e);this.initDelayedCursor(true)}this.selected=true})},setCursorByClick:function(t){var e=this.getSelectionStartFromPointer(t);if(t.shiftKey){if(e<this.selectionStart){this.setSelectionEnd(this.selectionStart);this.setSelectionStart(e)}else{this.setSelectionEnd(e)}}else{this.setSelectionStart(e);this.setSelectionEnd(e)}},getSelectionStartFromPointer:function(t){var e=this.getLocalPointer(t),i=0,r=0,s=0,n=0,o,a;for(var h=0,c=this._textLines.length;h<c;h++){a=this._textLines[h];s+=this._getHeightOfLine(this.ctx,h)*this.scaleY;var l=this._getLineWidth(this.ctx,h),f=this._getLineLeftOffset(l);r=f*this.scaleX;for(var u=0,d=a.length;u<d;u++){i=r;r+=this._getWidthOfChar(this.ctx,a[u],h,this.flipX?d-u:u)*this.scaleX;if(s<=e.y||r<=e.x){n++;continue}return this._getNewSelectionStartFromOffset(e,i,r,n+h,d)}if(e.y<s){return this._getNewSelectionStartFromOffset(e,i,r,n+h-1,d)}}if(typeof o==="undefined"){return this.text.length}},_getNewSelectionStartFromOffset:function(t,e,i,r,s){var n=t.x-e,o=i-t.x,a=o>n?0:1,h=r+a;if(this.flipX){h=s-h}if(h>this.text.length){h=this.text.length}return h}});fabric.util.object.extend(fabric.IText.prototype,{initHiddenTextarea:function(t){var e;if(t&&this.canvas){e=this.canvas.getPointer(t)}else{this.oCoords||this.setCoords();e=this.oCoords.tl}this.hiddenTextarea=fabric.document.createElement("textarea");this.hiddenTextarea.setAttribute("autocapitalize","off");this.hiddenTextarea.style.cssText="position: absolute; top: "+e.y+"px; left: "+e.x+"px; opacity: 0;"+" width: 0px; height: 0px; z-index: -999;";if(this.canvas){this.canvas.lowerCanvasEl.parentNode.appendChild(this.hiddenTextarea)}else{fabric.document.body.appendChild(this.hiddenTextarea)}fabric.util.addListener(this.hiddenTextarea,"keydown",this.onKeyDown.bind(this));fabric.util.addListener(this.hiddenTextarea,"keyup",this.onKeyUp.bind(this));fabric.util.addListener(this.hiddenTextarea,"input",this.onInput.bind(this));fabric.util.addListener(this.hiddenTextarea,"copy",this.copy.bind(this));fabric.util.addListener(this.hiddenTextarea,"cut",this.cut.bind(this));fabric.util.addListener(this.hiddenTextarea,"paste",this.paste.bind(this));fabric.util.addListener(this.hiddenTextarea,"compositionstart",this.onCompositionStart.bind(this));fabric.util.addListener(this.hiddenTextarea,"compositionupdate",this.onCompositionUpdate.bind(this));fabric.util.addListener(this.hiddenTextarea,"compositionend",this.onCompositionEnd.bind(this));if(!this._clickHandlerInitialized&&this.canvas){fabric.util.addListener(this.canvas.upperCanvasEl,"click",this.onClick.bind(this));this._clickHandlerInitialized=true}},_keysMap:{8:"removeChars",9:"exitEditing",27:"exitEditing",13:"insertNewline",33:"moveCursorUp",34:"moveCursorDown",35:"moveCursorRight",36:"moveCursorLeft",37:"moveCursorLeft",38:"moveCursorUp",39:"moveCursorRight",40:"moveCursorDown",46:"forwardDelete"},_ctrlKeysMapUp:{67:"copy",88:"cut"},_ctrlKeysMapDown:{65:"selectAll"},onClick:function(){this.hiddenTextarea&&this.hiddenTextarea.focus()},onKeyDown:function(t){if(!this.isEditing){return}if(t.keyCode in this._keysMap){this[this._keysMap[t.keyCode]](t)}else if(t.keyCode in this._ctrlKeysMapDown&&(t.ctrlKey||t.metaKey)){this[this._ctrlKeysMapDown[t.keyCode]](t)}else{return}t.stopImmediatePropagation();t.preventDefault();this.canvas&&this.canvas.renderAll()},onKeyUp:function(t){if(!this.isEditing||this._copyDone){this._copyDone=false;return}if(t.keyCode in this._ctrlKeysMapUp&&(t.ctrlKey||t.metaKey)){this[this._ctrlKeysMapUp[t.keyCode]](t)}else{return}t.stopImmediatePropagation();t.preventDefault();this.canvas&&this.canvas.renderAll()},onInput:function(t){if(!this.isEditing||this.inCompositionMode){return}var e=this.selectionStart||0,i=this.selectionEnd||0,r=this.text.length,s=this.hiddenTextarea.value.length,n,o,a;if(s>r){a=this._selectionDirection==="left"?i:e;n=s-r;o=this.hiddenTextarea.value.slice(a,a+n)}else{n=s-r+i-e;o=this.hiddenTextarea.value.slice(e,e+n)}this.insertChars(o);t.stopPropagation()},onCompositionStart:function(){this.inCompositionMode=true;this.prevCompositionLength=0;this.compositionStart=this.selectionStart},onCompositionEnd:function(){this.inCompositionMode=false},onCompositionUpdate:function(t){var e=t.data;this.selectionStart=this.compositionStart;this.selectionEnd=this.selectionEnd===this.selectionStart?this.compositionStart+this.prevCompositionLength:this.selectionEnd;this.insertChars(e,false);this.prevCompositionLength=e.length},forwardDelete:function(t){if(this.selectionStart===this.selectionEnd){if(this.selectionStart===this.text.length){return}this.moveCursorRight(t)}this.removeChars(t)},copy:function(t){if(this.selectionStart===this.selectionEnd){return}var e=this.getSelectedText(),i=this._getClipboardData(t);if(i){i.setData("text",e)}fabric.copiedText=e;fabric.copiedTextStyle=this.getSelectionStyles(this.selectionStart,this.selectionEnd);t.stopImmediatePropagation();t.preventDefault();this._copyDone=true},paste:function(t){var e=null,i=this._getClipboardData(t),r=true;if(i){e=i.getData("text").replace(/\r/g,"");if(!fabric.copiedTextStyle||fabric.copiedText!==e){r=false}}else{e=fabric.copiedText}if(e){this.insertChars(e,r)}t.stopImmediatePropagation();t.preventDefault()},cut:function(t){if(this.selectionStart===this.selectionEnd){return}this.copy(t);this.removeChars(t)},_getClipboardData:function(t){return t&&t.clipboardData||fabric.window.clipboardData},getDownCursorOffset:function(t,e){var i=e?this.selectionEnd:this.selectionStart,r=this.get2DCursorLocation(i),s,n,o=r.lineIndex,a=this._textLines[o].slice(0,r.charIndex),h=this._textLines[o].slice(r.charIndex),c=this._textLines[o+1]||"";if(o===this._textLines.length-1||t.metaKey||t.keyCode===34){return this.text.length-i}var l=this._getLineWidth(this.ctx,o);n=this._getLineLeftOffset(l);var f=n;for(var u=0,d=a.length;u<d;u++){s=a[u];f+=this._getWidthOfChar(this.ctx,s,o,u)}var g=this._getIndexOnNextLine(r,c,f);return h.length+1+g},_getIndexOnNextLine:function(t,e,i){var r=t.lineIndex+1,s=this._getLineWidth(this.ctx,r),n=this._getLineLeftOffset(s),o=n,a=0,h;for(var c=0,l=e.length;c<l;c++){var f=e[c],u=this._getWidthOfChar(this.ctx,f,r,c);o+=u;if(o>i){h=true;var d=o-u,g=o,p=Math.abs(d-i),v=Math.abs(g-i);a=v<p?c+1:c;break}}if(!h){a=e.length}return a},moveCursorDown:function(t){this.abortCursorAnimation();this._currentCursorOpacity=1;var e=this.getDownCursorOffset(t,this._selectionDirection==="right");if(t.shiftKey){this.moveCursorDownWithShift(e)}else{this.moveCursorDownWithoutShift(e)}this.initDelayedCursor()},moveCursorDownWithoutShift:function(t){this._selectionDirection="right";this.setSelectionStart(this.selectionStart+t);this.setSelectionEnd(this.selectionStart)},swapSelectionPoints:function(){var t=this.selectionEnd;this.setSelectionEnd(this.selectionStart);this.setSelectionStart(t)},moveCursorDownWithShift:function(t){if(this.selectionEnd===this.selectionStart){this._selectionDirection="right"}if(this._selectionDirection==="right"){this.setSelectionEnd(this.selectionEnd+t)}else{this.setSelectionStart(this.selectionStart+t)}if(this.selectionEnd<this.selectionStart&&this._selectionDirection==="left"){this.swapSelectionPoints();this._selectionDirection="right"}if(this.selectionEnd>this.text.length){this.setSelectionEnd(this.text.length)}},getUpCursorOffset:function(t,e){var i=e?this.selectionEnd:this.selectionStart,r=this.get2DCursorLocation(i),s=r.lineIndex;if(s===0||t.metaKey||t.keyCode===33){return i}var n=this._textLines[s].slice(0,r.charIndex),o=this._textLines[s-1]||"",a,h=this._getLineWidth(this.ctx,r.lineIndex),c=this._getLineLeftOffset(h),l=c;for(var f=0,u=n.length;f<u;f++){a=n[f];l+=this._getWidthOfChar(this.ctx,a,s,f)}var d=this._getIndexOnPrevLine(r,o,l);return o.length-d+n.length},_getIndexOnPrevLine:function(t,e,i){var r=t.lineIndex-1,s=this._getLineWidth(this.ctx,r),n=this._getLineLeftOffset(s),o=n,a=0,h;for(var c=0,l=e.length;c<l;c++){var f=e[c],u=this._getWidthOfChar(this.ctx,f,r,c);o+=u;if(o>i){h=true;var d=o-u,g=o,p=Math.abs(d-i),v=Math.abs(g-i);a=v<p?c:c-1;break}}if(!h){a=e.length-1}return a},moveCursorUp:function(t){this.abortCursorAnimation();this._currentCursorOpacity=1;var e=this.getUpCursorOffset(t,this._selectionDirection==="right");if(t.shiftKey){this.moveCursorUpWithShift(e)}else{this.moveCursorUpWithoutShift(e)}this.initDelayedCursor()},moveCursorUpWithShift:function(t){if(this.selectionEnd===this.selectionStart){this._selectionDirection="left"}if(this._selectionDirection==="right"){this.setSelectionEnd(this.selectionEnd-t)}else{this.setSelectionStart(this.selectionStart-t)}if(this.selectionEnd<this.selectionStart&&this._selectionDirection==="right"){this.swapSelectionPoints();this._selectionDirection="left"}},moveCursorUpWithoutShift:function(t){if(this.selectionStart===this.selectionEnd){this.setSelectionStart(this.selectionStart-t)}this.setSelectionEnd(this.selectionStart);this._selectionDirection="left"},moveCursorLeft:function(t){if(this.selectionStart===0&&this.selectionEnd===0){return}this.abortCursorAnimation();this._currentCursorOpacity=1;if(t.shiftKey){this.moveCursorLeftWithShift(t)}else{this.moveCursorLeftWithoutShift(t)}this.initDelayedCursor()},_move:function(t,e,i){var r=e==="selectionStart"?"setSelectionStart":"setSelectionEnd";if(t.altKey){this[r](this["findWordBoundary"+i](this[e]))}else if(t.metaKey||t.keyCode===35||t.keyCode===36){this[r](this["findLineBoundary"+i](this[e]))}else{this[r](this[e]+(i==="Left"?-1:1))}},_moveLeft:function(t,e){this._move(t,e,"Left")},_moveRight:function(t,e){this._move(t,e,"Right")},moveCursorLeftWithoutShift:function(t){this._selectionDirection="left";if(this.selectionEnd===this.selectionStart){this._moveLeft(t,"selectionStart")}this.setSelectionEnd(this.selectionStart)},moveCursorLeftWithShift:function(t){if(this._selectionDirection==="right"&&this.selectionStart!==this.selectionEnd){this._moveLeft(t,"selectionEnd")}else{this._selectionDirection="left";this._moveLeft(t,"selectionStart")}},moveCursorRight:function(t){if(this.selectionStart>=this.text.length&&this.selectionEnd>=this.text.length){return}this.abortCursorAnimation();this._currentCursorOpacity=1;if(t.shiftKey){this.moveCursorRightWithShift(t)}else{this.moveCursorRightWithoutShift(t)}this.initDelayedCursor()},moveCursorRightWithShift:function(t){if(this._selectionDirection==="left"&&this.selectionStart!==this.selectionEnd){this._moveRight(t,"selectionStart")}else{this._selectionDirection="right";this._moveRight(t,"selectionEnd")}},moveCursorRightWithoutShift:function(t){this._selectionDirection="right";if(this.selectionStart===this.selectionEnd){this._moveRight(t,"selectionStart");this.setSelectionEnd(this.selectionStart)}else{this.setSelectionEnd(this.selectionEnd+this.getNumNewLinesInSelectedText());this.setSelectionStart(this.selectionEnd)}},removeChars:function(t){if(this.selectionStart===this.selectionEnd){this._removeCharsNearCursor(t)}else{this._removeCharsFromTo(this.selectionStart,this.selectionEnd)}this.setSelectionEnd(this.selectionStart);this._removeExtraneousStyles();this.canvas&&this.canvas.renderAll();this.setCoords();this.fire("changed");this.canvas&&this.canvas.fire("text:changed",{target:this})},_removeCharsNearCursor:function(t){if(this.selectionStart===0){return}if(t.metaKey){var e=this.findLineBoundaryLeft(this.selectionStart);this._removeCharsFromTo(e,this.selectionStart);this.setSelectionStart(e)}else if(t.altKey){var i=this.findWordBoundaryLeft(this.selectionStart);this._removeCharsFromTo(i,this.selectionStart);this.setSelectionStart(i)}else{this._removeSingleCharAndStyle(this.selectionStart);this.setSelectionStart(this.selectionStart-1)}}});(function(){var t=fabric.util.toFixed,e=fabric.Object.NUM_FRACTION_DIGITS;fabric.util.object.extend(fabric.IText.prototype,{_setSVGTextLineText:function(t,e,i,r,s,n){if(!this._getLineStyle(t)){fabric.Text.prototype._setSVGTextLineText.call(this,t,e,i,r,s)}else{this._setSVGTextLineChars(t,e,i,r,n)}},_setSVGTextLineChars:function(t,e,i,r,s){var n=this._textLines[t],o=0,a=this._getLineLeftOffset(this._getLineWidth(this.ctx,t))-this.width/2,h=this._getSVGLineTopOffset(t),c=this._getHeightOfLine(this.ctx,t);for(var l=0,f=n.length;l<f;l++){var u=this._getStyleDeclaration(t,l)||{};e.push(this._createTextCharSpan(n[l],u,a,h.lineTop+h.offset,o));var d=this._getWidthOfChar(this.ctx,n[l],t,l);if(u.textBackgroundColor){s.push(this._createTextCharBg(u,a,h.lineTop,c,d,o))}o+=d}},_getSVGLineTopOffset:function(t){var e=0,i=0;for(var r=0;r<t;r++){e+=this._getHeightOfLine(this.ctx,r)}i=this._getHeightOfLine(this.ctx,r);return{lineTop:e,offset:(this._fontSizeMult-this._fontSizeFraction)*i/(this.lineHeight*this._fontSizeMult)}},_createTextCharBg:function(i,r,s,n,o,a){return['		<rect fill="',i.textBackgroundColor,'" x="',t(r+a,e),'" y="',t(s-this.height/2,e),'" width="',t(o,e),'" height="',t(n/this.lineHeight,e),'"></rect>\n'].join("")},_createTextCharSpan:function(i,r,s,n,o){var a=this.getSvgStyles.call(fabric.util.object.extend({visible:true,fill:this.fill,stroke:this.stroke,type:"text",getSvgFilter:fabric.Object.prototype.getSvgFilter},r));return['			<tspan x="',t(s+o,e),'" y="',t(n-this.height/2,e),'" ',r.fontFamily?'font-family="'+r.fontFamily.replace(/"/g,"'")+'" ':"",r.fontSize?'font-size="'+r.fontSize+'" ':"",r.fontStyle?'font-style="'+r.fontStyle+'" ':"",r.fontWeight?'font-weight="'+r.fontWeight+'" ':"",r.textDecoration?'text-decoration="'+r.textDecoration+'" ':"",'style="',a,'">',fabric.util.string.escapeXml(i),"</tspan>\n"].join("")}})})();(function(t){"use strict";var e=t.fabric||(t.fabric={}),i=e.util.object.clone;e.Textbox=e.util.createClass(e.IText,e.Observable,{type:"textbox",minWidth:20,dynamicMinWidth:0,__cachedLines:null,lockScalingY:true,lockScalingFlip:true,initialize:function(t,i){this.ctx=e.util.createCanvasElement().getContext("2d");this.callSuper("initialize",t,i);this.setControlsVisibility(e.Textbox.getTextboxControlVisibility());this._dimensionAffectingProps.width=true},_initDimensions:function(t){if(this.__skipDimension){return}if(!t){t=e.util.createCanvasElement().getContext("2d");this._setTextStyles(t)}this.dynamicMinWidth=0;this._textLines=this._splitTextIntoLines();if(this.dynamicMinWidth>this.width){this._set("width",this.dynamicMinWidth)}this._clearCache();this.height=this._getTextHeight(t)},_generateStyleMap:function(){var t=0,e=0,i=0,r={};for(var s=0;s<this._textLines.length;s++){if(this.text[i]==="\n"){e=0;i++;t++}else if(this.text[i]===" "){e++;i++}r[s]={line:t,offset:e};i+=this._textLines[s].length;e+=this._textLines[s].length}return r},_getStyleDeclaration:function(t,e,i){if(this._styleMap){var r=this._styleMap[t];if(!r){return i?{}:null}t=r.line;e=r.offset+e}return this.callSuper("_getStyleDeclaration",t,e,i)},_setStyleDeclaration:function(t,e,i){var r=this._styleMap[t];t=r.line;e=r.offset+e;this.styles[t][e]=i},_deleteStyleDeclaration:function(t,e){var i=this._styleMap[t];t=i.line;e=i.offset+e;delete this.styles[t][e]},_getLineStyle:function(t){var e=this._styleMap[t];return this.styles[e.line]},_setLineStyle:function(t,e){var i=this._styleMap[t];this.styles[i.line]=e},_deleteLineStyle:function(t){var e=this._styleMap[t];delete this.styles[e.line]},_wrapText:function(t,e){var i=e.split(this._reNewline),r=[],s;for(s=0;s<i.length;s++){r=r.concat(this._wrapLine(t,i[s],s))}return r},_measureText:function(t,e,i,r){var s=0;r=r||0;for(var n=0,o=e.length;n<o;n++){s+=this._getWidthOfChar(t,e[n],i,n+r)}return s},_wrapLine:function(t,e,i){var r=0,s=[],n="",o=e.split(" "),a="",h=0,c=" ",l=0,f=0,u=0,d=true;for(var g=0;g<o.length;g++){a=o[g];l=this._measureText(t,a,i,h);h+=a.length;r+=f+l;if(r>=this.width&&!d){s.push(n);n="";r=l;d=true}if(!d){n+=c}n+=a;f=this._measureText(t,c,i,h);h++;d=false;if(l>u){u=l}}g&&s.push(n);if(u>this.dynamicMinWidth){this.dynamicMinWidth=u}return s},_splitTextIntoLines:function(){var t=this.textAlign;this.ctx.save();this._setTextStyles(this.ctx);this.textAlign="left";var e=this._wrapText(this.ctx,this.text);this.textAlign=t;this.ctx.restore();this._textLines=e;this._styleMap=this._generateStyleMap();return e},setOnGroup:function(t,e){if(t==="scaleX"){this.set("scaleX",Math.abs(1/e));this.set("width",this.get("width")*e/(typeof this.__oldScaleX==="undefined"?1:this.__oldScaleX));this.__oldScaleX=e}},get2DCursorLocation:function(t){if(typeof t==="undefined"){t=this.selectionStart}var e=this._textLines.length,i=0;for(var r=0;r<e;r++){var s=this._textLines[r],n=s.length;if(t<=i+n){return{lineIndex:r,charIndex:t-i}}i+=n;if(this.text[i]==="\n"||this.text[i]===" "){i++}}return{lineIndex:e-1,charIndex:this._textLines[e-1].length}},_getCursorBoundariesOffsets:function(t,e){var i=0,r=0,s=this.get2DCursorLocation(),n=this._textLines[s.lineIndex].split(""),o=this._getLineLeftOffset(this._getLineWidth(this.ctx,s.lineIndex));for(var a=0;a<s.charIndex;a++){r+=this._getWidthOfChar(this.ctx,n[a],s.lineIndex,a)}for(a=0;a<s.lineIndex;a++){i+=this._getHeightOfLine(this.ctx,a)}if(e==="cursor"){i+=(1-this._fontSizeFraction)*this._getHeightOfLine(this.ctx,s.lineIndex)/this.lineHeight-this.getCurrentCharFontSize(s.lineIndex,s.charIndex)*(1-this._fontSizeFraction)}return{top:i,left:r,lineLeft:o}},getMinWidth:function(){return Math.max(this.minWidth,this.dynamicMinWidth)},toObject:function(t){return e.util.object.extend(this.callSuper("toObject",t),{minWidth:this.minWidth})}});e.Textbox.fromObject=function(t){return new e.Textbox(t.text,i(t))};e.Textbox.getTextboxControlVisibility=function(){return{tl:false,tr:false,br:false,bl:false,ml:true,mt:false,mr:true,mb:false,mtr:true}};e.Textbox.instances=[]})(typeof exports!=="undefined"?exports:this);(function(){var t=fabric.Canvas.prototype._setObjectScale;fabric.Canvas.prototype._setObjectScale=function(e,i,r,s,n,o,a){var h=i.target;if(h instanceof fabric.Textbox){var c=h.width*(e.x/i.scaleX/(h.width+h.strokeWidth));if(c>=h.getMinWidth()){h.set("width",c);return true}}else{return t.call(fabric.Canvas.prototype,e,i,r,s,n,o,a)}};fabric.Group.prototype._refreshControlsVisibility=function(){if(typeof fabric.Textbox==="undefined"){return}for(var t=this._objects.length;t--;){if(this._objects[t]instanceof fabric.Textbox){this.setControlsVisibility(fabric.Textbox.getTextboxControlVisibility());return}}};var e=fabric.util.object.clone;fabric.util.object.extend(fabric.Textbox.prototype,{_removeExtraneousStyles:function(){for(var t in this._styleMap){if(!this._textLines[t]){delete this.styles[this._styleMap[t].line]}}},insertCharStyleObject:function(t,e,i){var r=this._styleMap[t];t=r.line;e=r.offset+e;fabric.IText.prototype.insertCharStyleObject.apply(this,[t,e,i])},insertNewlineStyleObject:function(t,e,i){var r=this._styleMap[t];t=r.line;e=r.offset+e;fabric.IText.prototype.insertNewlineStyleObject.apply(this,[t,e,i])},shiftLineStyles:function(t,i){var r=e(this.styles),s=this._styleMap[t];t=s.line;for(var n in this.styles){var o=parseInt(n,10);if(o>t){this.styles[o+i]=r[o];if(!r[o-i]){delete this.styles[o]}}}},_getTextOnPreviousLine:function(t){var e=this._textLines[t-1];while(this._styleMap[t-2]&&this._styleMap[t-2].line===this._styleMap[t-1].line){e=this._textLines[t-2]+e;t--}return e},removeStyleObject:function(t,e){var i=this.get2DCursorLocation(e),r=this._styleMap[i.lineIndex],s=r.line,n=r.offset+i.charIndex;this._removeStyleObject(t,i,s,n)}})})();(function(){var t=fabric.IText.prototype._getNewSelectionStartFromOffset;fabric.IText.prototype._getNewSelectionStartFromOffset=function(e,i,r,s,n){s=t.call(this,e,i,r,s,n);var o=0,a=0;for(var h=0;h<this._textLines.length;h++){o+=this._textLines[h].length;if(o+a>=s){break}if(this.text[o+a]==="\n"||this.text[o+a]===" "){a++}}return s-h+a}})();(function(){if(typeof document!=="undefined"&&typeof window!=="undefined"){return}var DOMParser=require("xmldom").DOMParser,URL=require("url"),HTTP=require("http"),HTTPS=require("https"),Canvas=require("canvas"),Image=require("canvas").Image;function request(t,e,i){var r=URL.parse(t);if(!r.port){r.port=r.protocol.indexOf("https:")===0?443:80}var s=r.protocol.indexOf("https:")===0?HTTPS:HTTP,n=s.request({hostname:r.hostname,port:r.port,path:r.path,method:"GET"},function(t){var r="";if(e){t.setEncoding(e)}t.on("end",function(){i(r)});t.on("data",function(e){if(t.statusCode===200){r+=e}})});n.on("error",function(t){if(t.errno===process.ECONNREFUSED){fabric.log("ECONNREFUSED: connection refused to "+r.hostname+":"+r.port)}else{fabric.log(t.message)}i(null)});n.end()}function requestFs(t,e){var i=require("fs");i.readFile(t,function(t,i){if(t){fabric.log(t);throw t}else{e(i)}})}fabric.util.loadImage=function(t,e,i){function r(r){if(r){s.src=new Buffer(r,"binary");s._src=t;e&&e.call(i,s)}else{s=null;e&&e.call(i,null,true)}}var s=new Image;if(t&&(t instanceof Buffer||t.indexOf("data")===0)){s.src=s._src=t;e&&e.call(i,s)}else if(t&&t.indexOf("http")!==0){requestFs(t,r)}else if(t){request(t,"binary",r)}else{e&&e.call(i,t)}};fabric.loadSVGFromURL=function(t,e,i){t=t.replace(/^\n\s*/,"").replace(/\?.*$/,"").trim();if(t.indexOf("http")!==0){requestFs(t,function(t){fabric.loadSVGFromString(t.toString(),e,i)})}else{request(t,"",function(t){fabric.loadSVGFromString(t,e,i)})}};fabric.loadSVGFromString=function(t,e,i){var r=(new DOMParser).parseFromString(t);fabric.parseSVGDocument(r.documentElement,function(t,i){e&&e(t,i)},i)};fabric.util.getScript=function(url,callback){request(url,"",function(body){eval(body);callback&&callback()})};fabric.Image.fromObject=function(t,e){fabric.util.loadImage(t.src,function(i){var r=new fabric.Image(i);r._initConfig(t);r._initFilters(t.filters,function(i){r.filters=i||[];r._initFilters(t.resizeFilters,function(t){r.resizeFilters=t||[];e&&e(r)})})})};fabric.createCanvasForNode=function(t,e,i,r){r=r||i;var s=fabric.document.createElement("canvas"),n=new Canvas(t||600,e||600,r);s.style={};s.width=n.width;s.height=n.height;var o=fabric.Canvas||fabric.StaticCanvas,a=new o(s,i);a.contextContainer=n.getContext("2d");a.nodeCanvas=n;a.Font=Canvas.Font;return a};fabric.StaticCanvas.prototype.createPNGStream=function(){return this.nodeCanvas.createPNGStream()};fabric.StaticCanvas.prototype.createJPEGStream=function(t){return this.nodeCanvas.createJPEGStream(t)};var origSetWidth=fabric.StaticCanvas.prototype.setWidth;fabric.StaticCanvas.prototype.setWidth=function(t,e){origSetWidth.call(this,t,e);this.nodeCanvas.width=t;return this};if(fabric.Canvas){fabric.Canvas.prototype.setWidth=fabric.StaticCanvas.prototype.setWidth}var origSetHeight=fabric.StaticCanvas.prototype.setHeight;fabric.StaticCanvas.prototype.setHeight=function(t,e){origSetHeight.call(this,t,e);this.nodeCanvas.height=t;return this};if(fabric.Canvas){fabric.Canvas.prototype.setHeight=fabric.StaticCanvas.prototype.setHeight}})();
//# sourceMappingURL=fabric.map.js